/** * 二维数组按照某字段进行排序 * @param $array * @param $sort_key * @param string $sort * @return array */function array_sort($array, $sort_key, $sort = 'DESC'){ $sort = array( 'direction' => 'SORT_' . strtoupper($sort), //排序顺序标志 SORT_DESC 降序;SORT_ASC 升序 'field' => $sort_key, //排序字段 ); $arrSort = array(); foreach($array AS $uniqid => $row) { foreach($row AS $key => $value) { $arrSort[$key][$uniqid] = $value; } } if($sort['direction']) { array_multisort($arrSort[$sort['field']], constant($sort['direction']), $array); } return $array;}
来源:网络