这是我的2D阵列:
$a = array(
'6' => array(10, 5),
'5' => array(20, 7),
'40' => array(15, 9)
);
我可以使用array_multisort
简单地对其进行排序:
foreach ($a as $k => $r) {
$keys[$k] = $r[1];
}
array_multisort($keys, SORT_DESC, $a);
但它会清除键('6','5','40'):
Array
(
[0] => Array
(
[0] => 15
[1] => 9
)
[1] => Array
(
[0] => 20
[1] => 7
)
[2] => Array
(
[0] => 10
[1] => 5
)
)
array_multisort
是否有任何参数来保存数组键?