我有一个带有多维数组的数组,就像我将大尺寸数组拆分成块大块而且我正在尝试应用asc和desc这样的排序...数组函数就像array_multisort,usort我已经尝试但它根本没有按照我预期的结果工作..
数组是
<pre>Array
(
[0] => Array
(
[0] => Array
(
[rate] => 16.8
[details] => Array
(
[address] => 280 Lavender Street
[city] => Singapore
)
[packages] => Array
(
[0] => Array
(
[avg_rate] => 16.8
)
)
)
[1] => Array
(
[rate] => 16.8
[details] => Array
(
[address] => 280 Lavender Street
[city] => Singapore
)
[packages] => Array
(
[0] => Array
(
[avg_rate] => 16.8
)
)
)
...
)
[1] => Array
(
[0] => Array
(
[rate] => 16.8
[details] => Array
(
[address] => 280 Lavender Street
[city] => Singapore
)
[packages] => Array
(
[0] => Array
(
[avg_rate] => 16.8
)
)
)
[1] => Array
(
[rate] => 16.8
[details] => Array
(
[address] => 280 Lavender Street
[city] => Singapore
)
[packages] => Array
(
[0] => Array
(
[avg_rate] => 16.8
)
)
)
...
)
和我的功能
usort($result['list'], function($a, $b) {
if($a['packages'][0]['avg_rate'] == $b['packages'][0]['avg_rate'])
return 0;
return $a['packages'][0]['avg_rate'] < $b['packages'][0]['avg_rate'] ? -1 : 1;
});
任何建议