我有以下我想排序的多維數組。PHP Array按多個值排序
欲由total_points最裏面的數組進行排序,然後tiebraker1,2和3
實施例:
Array
(
[1] => Array
(
[1] => Array
(
[userid] => 17
[total_points] => 16
[tiebraker1] => 1
[tiebraker2] => 2
[tiebraker3] => 1
)
[2] => Array
(
[userid] => 29
[total_points] => 16
[tiebraker1] => 1
[tiebraker2] => 2
[tiebraker3] => 9
)
)
[2] => Array
(
[1] => Array
(
[userid] => 26
[total_points] => 26
[tiebraker1] => 2
[tiebraker2] => 2
[tiebraker3] => 4
)
[2] => Array
(
[userid] => 17
[total_points] => 26
[tiebraker1] => 3
[tiebraker2] => 2
[tiebraker3] => 4
)
)
)
結果:
Array
(
[1] => Array
(
[1] => Array
(
[userid] => 29
[total_points] => 16
[tiebraker1] => 1
[tiebraker2] => 2
[tiebraker3] => 9
)
[2] => Array
(
[userid] => 17
[total_points] => 16
[tiebraker1] => 1
[tiebraker2] => 2
[tiebraker3] => 1
)
)
[2] => Array
(
[1] => Array
(
[userid] => 17
[total_points] => 26
[tiebraker1] => 3
[tiebraker2] => 2
[tiebraker3] => 4
)
[2] => Array
(
[userid] => 26
[total_points] => 26
[tiebraker1] => 2
[tiebraker2] => 2
[tiebraker3] => 4
)
)
)
我嘗試使用在array_multisort但我不能配置它正確。
在此先感謝您的幫助!
可能重複[按值排序PHP多維數組](http://stackoverflow.com/questions/2699086/php-sort-multidimensional-array-by-value) –