日期:2014-05-17 浏览次数:20439 次
$a=array( 0=>array(3=>9), 1=>array(2=>9), 2=>array(6=>5), 3=>array(1=>15), 4=>array(2=>4), );
$b=array( 0=>array(1=>15), 1=>array(3=>9), 2=>array(2=>9), 3=>array(6=>5), 4=>array(2=>4), );
$a=array( 0=>array(3=>9), 1=>array(2=>9), 2=>array(6=>5), 3=>array(1=>15), 4=>array(2=>4), ); foreach($a as $v) { $r[] = current($v); $k[] = key($v); } array_multisort($r, SORT_DESC, $k, SORT_DESC, $a); print_r($a);
------解决方案--------------------
…… usort($a, create_function('$m, $n', 'return current($m)==current($n) ? (key($m)==key($n) ? 0 : key($m)<key($n)) : current($m)<current($n);')); print_r($a); /** ( [0] => Array ( [1] => 15 ) [1] => Array ( [3] => 9 ) [2] => Array ( [2] => 9 ) [3] => Array ( [6] => 5 ) [4] => Array ( [2] => 4 ) ) /**/