<?php
//快速排序
function quick_sort($arr){
if(!is_array($arr)){
return false;
}
$length = count($arr);
if($length <= 1) return $arr;
$left = $right = array();
for($i = 1;$i < $length;$i++){
if($arr[$i] < $arr[0]){
$left[] = $arr[$i];
}else{
$right[] = $arr[$i];
}
}
$left = quick_sort($left);
$right = quick_sort($right);
return array_merge($left,$arr[0],$right);
}