通过array_multisort来做二维数组排序,详细用法https://www.runoob.com/php/func-array-multisort.html
$array 要排序得数组
$field 根据哪个字段排序
$sort SORT_DESC降序 SORT_ASC升序 (默认)
function arraySort($array, $field, $sort = 'SORT_DESC')
{
$arrSort = array();
foreach ($array as $uniqid => $row) {
foreach ($row as $key => $value) {
$arrSort[$key][$uniqid] = $value;
}
}
array_multisort($arrSort[$field], constant($sort), $array);
return $array;
}
调用此方法即可实现二维数组排序