二维数组排序

public function arraySort($array,$keys,$sort='asc') {
$newArr = $valArr = array();
foreach ($array as $key=>$value) {
$valArr[$key] = $value[$keys];
}
($sort == 'asc') ? asort($valArr) : arsort($valArr);
reset($valArr);
foreach($valArr as $key=>$value) {
$newArr[$key] = $array[$key];
}
return $newArr;
}
posted @ 2020-08-26 15:10  一席青衫  阅读(94)  评论(0编辑  收藏  举报