二维数组排序,利用array_multisort函数实现
/** * @brief 二维数组排序 * @param $data * @param $field * @param $direction * @return mixed */
private function arraySort($data, $field, $direction) {
$sort = array(
'direction' => $direction, //排序顺序标志 SORT_DESC 降序;SORT_ASC 升序
'field' => $field, //排序字段
);
$arrSort = array();
foreach($data AS $uniqid => $row){
foreach($row AS $key=>$value){
$arrSort[$key][$uniqid] = $value;
}
}
if($sort['direction']){
array_multisort($arrSort[$sort['field']], constant($sort['direction']), $data);
}
return $data;
}