//$sort 要排序的键
//$d 默认是降序排序,带上参后是升序
function array_sort($a,$sort,$d=”) {
$num=count($a);
if(!$d){
for($i=0;$i<$num;$i++){
for($j=0;$j<$num-1;$j++){
if($a[$j][$sort] > $a[$j+1][$sort]){
foreach ($a[$j] as $key=>$temp){
$t=$a[$j+1][$key];
$a[$j+1][$key]=$a[$j][$key];
$a[$j][$key]=$t;
}
}
}
}
}
else{
for($i=0;$i<$num;$i++){
for($j=0;$j<$num-1;$j++){
if($a[$j][$sort] < $a[$j+1][$sort]){
foreach ($a[$j] as $key=>$temp){
$t=$a[$j+1][$key];
$a[$j+1][$key]=$a[$j][$key];
$a[$j][$key]=$t;
}
}
}
}
}
return $a;
}