if(!function_exists('multisortCharts')) { /** * 二维数组排序 * @author lulijuan * @param type $data * @param type $key * @return type */ function multisortCharts($data, $key = 'price') { $sort = array( 'direction' => 'SORT_DESC', //排序顺序标志 SORT_DESC 降序;SORT_ASC 升序 'field' => $key, //排序字段 ); $arrSort = []; foreach($data AS $uniqid => $row){ foreach($row AS $key=>$value){ $arrSort[$key][$uniqid] = $value; } } if($sort['direction']){ isset($arrSort[$sort['field']]) ? array_multisort($arrSort[$sort['field']], constant($sort['direction']), $data) : []; } return $data; } }
评论