PHP 按二维数组的键值排序
/** * 按二维数组的键值排序 * @param unknown $array 二维数组 * @param unknown $key 二维数组的键值 * @param string $order 升序/降序 * @return multitype:unknown 返回排序后的数组 */ public static function arr_sort_in_key($array, $key, $order = "asc") { $arr_nums = $arr = array(); foreach ($array as $k => $v) { $arr_nums[$k] = $v[$key]; } if($order=='asc') { asort($arr_nums); } else { arsort($arr_nums); } foreach($arr_nums as $k=>$v) { $arr[] = $array[$k]; } return $arr; }