$arr = array ( 0 => array ( 'id' => '4', 0 => '4', 'address' => 'Гродно', 2 => 'Гродно', 'name' => 'Елена', 11 => 'Елена','distance' => '246.37229654695437', 14 => '246.37229654695437', ), 1 => array ( 'id' => '5', 0 => '5', 'address' => 'Брест', 2 => 'Брест', 'name' => 'Сергей', 11 => 'Сергей', 'distance' => '328.14766422409343', 14 => '328.14766422409343', ), 2 => array ( 'id' => '4', 0 => '4', 'address' => 'Гродно', 2 => 'Гродно', 'name' => 'Елена', 11 => 'Елена','distance' => '0', 14 => '0', ));
print_r(array_sort($arr, 'distance', SORT_DESC));
function array_sort($array, $on, $order=SORT_ASC)
{
$new_array = array();
$sortable_array = array();
if (count($array) > 0) {
foreach ($array as $k => $v) {
if (is_array($v)) {
foreach ($v as $k2 => $v2) {
if ($k2 == $on) {
$sortable_array[$k] = $v2;
}
}
} else {
$sortable_array[$k] = $v;
}
}
switch ($order) {
case SORT_ASC:
asort($sortable_array);
break;
case SORT_DESC:
arsort($sortable_array);
break;
}
foreach ($sortable_array as $k => $v) {
$new_array[$k] = $array[$k];
}
}
return $new_array;
}