多维数组排序
$array = array(
0=>array('id'=>50,'name'=>'Jack'),
1=>array('id'=>8,'name'=>'Tom'),
2=>array('id'=>9,'name'=>'Peter')
);
function sortArrByOneField(&$array, $field, $desc = false){
$fieldArr = array();
foreach ($array as $k => $v) {
$fieldArr[$k] = $v[$field];
}
$sort = $desc == false ? SORT_ASC : SORT_DESC;
array_multisort($fieldArr, $sort, $array);
}
sortArrByOneField($array,'id');
dd($array);