function sortByOneKeyx(array $array, $key, $asc = true) { $result = array(); $values = array(); foreach ($array as $id => $value) { $values[$id] = isset($value[$key]) ? $value[$key] : ''; } if ($asc) { asort($values); } else { arsort($values); } foreach ($values as $key => $value) { $result[$key] = $array[$key]; } return $result; }