function array_sort($arr,$keys,$orderby='asc'){ $keysvalue = $new_array = array(); foreach ($arr as $k=>$v){ $keysvalue[$k] = $v[$keys]; } //对key集合排序 if($orderby== 'asc'){ asort($keysvalue); }else{ arsort($keysvalue); } reset($keysvalue); //根据排序好的key按顺序从原数组中获取对应的值 foreach ($keysvalue as $k=>$v){ $new_array[] = $arr[$k]; } return $new_array; }