Array
(
[0] => Array
(
[name] => name_1
[rate] => 1
)
[1] => Array
(
[name] => name_2
[rate] => 2
)
[3] => Array
(
[name] => name_3
[rate] => -3
)
)
Array
(
[0] => Array
(
[name] => name_2
[rate] => 2
)
[1] => Array
(
[name] => name_1
[rate] =>1
)
[3] => Array
(
[name] => name_3
[rate] => -3
)
)
<?php
$arr = array(
array(
'name' => 'name_1',
'rate' => 1
),
array(
'name' => 'name_1',
'rate' => 2
),
array(
'name' => 'name_1',
'rate' => -3
),
);
uasort($arr, function($a, $b){
if ($a['rate'] == $b['rate']) {
return 0;
}
return ($a['rate'] < $b['rate']) ? -1 : 1;
});
print_r($arr);