<?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 个元素之后它开始给出循环最大错误............知道吗?