请问数组怎么多条件排序 array( '000-00'=array( 'qty'=20, 'price'=200 ), '0001-00'=array( 'qty'=10, 'price'=100 ), '0002-00'=array( 'qty'=30, 【本文来自鸿网互联 (http://www.68idc.cn)】'price'=50 ) ) 请问怎么样先按qty由小到大排序,然后按Price
请问数组怎么多条件排序
$a = array(<br /> '000-00'=>array(<br /> 'qty'=>20,<br /> 'price'=>200<br /> ),<br /> '0001-00'=>array(<br /> 'qty'=>10,<br /> 'price'=>100<br /> ),<br /> '0002-00'=>array(<br /> 'qty'=>30,<br /> 'price'=>50<br /> )<br /> <br /> );<br /> foreach($a as $k=>$v) {<br /> $qty[] = $v['qty'];<br /> $price[] = $v['price'];<br /> }<br /> array_multisort($qty, $price, SORT_DESC, $a);<br /> print_r($a);
Array<br /> (<br /> [0001-00] => Array<br /> (<br /> [qty] => 10<br /> [price] => 100<br /> )<br /> <br /> [000-00] => Array<br /> (<br /> [qty] => 20<br /> [price] => 200<br /> )<br /> <br /> [0002-00] => Array<br /> (<br /> [qty] => 30<br /> [price] => 50<br /> )<br /> <br /> )<br /> <br />