<?php
function array_sort($array,$keys,$type='desc'){ //asc为从小到大,desc为从大到小排序
//$array为要排序的数组,$keys为要用来排序的键名,$type默认为升序排序
$keysvalue = $new_array = array();
foreach ($array as $k=>$v){
$keysvalue[$k] = $v[$keys];
}
if($type == 'asc'){
asort($keysvalue);
}
else
{
arsort($keysvalue);
}
reset($keysvalue);
foreach ($keysvalue as $k=>$v){
$new_array[$k] = $array[$k];
}
return $new_array;
}
//指定数组以$keys键值排序