<?php
// Recursive version:
function quicksort($seq) {
if(!count($seq)) return $seq;
$pivot= $seq[0];
$low = $high = array();
$length = count($seq);
for($i=1; $i < $length; $i++) {
if($seq[$i] <= $pivot) {
$low [] = $seq[$i];
} else {
$high[] = $seq[$i];
}
}
return array_merge(quicksort($low), array($pivot), quicksort($high));
}
//Let's try some examples
$myarr = array(25,5,3,4,17,1,88,8);
$final = quicksort($myarr);
print_r($final);
$final = quicksort($final);
print_r($final);
$strarray = array("mark","wes","mj","bruce","ming","lance","vince");
var_dump(quicksort($strarray));
?>
我是php新手,我想知道如何让这个循环超过100次。我有一个数组2500 int元素,我需要快速排序并显示结果,但是在100元素后它开始给出循环最大错误..........任何想法?