<?php
function quickSort($startID,$endID) {
global $a;
$pivot = $a[(int)(($startID + $endID)/2)];
$left = $startID;
$right = $endID;
while (true) {
while ($a[$left] < $pivot) {
$left++;
}
while ($pivot < $a[$right]) {
$right--;
}
if ($right <=$left) {
break;
}
$tmp = $a[$left];
$a[$left] = $a[$right];
$a[$right] = $tmp;
$left++;
}
if ($startID < $left-1) {
quickSort($right+1,$endID);
}
}
$a = array(10,3,1,9,7,6,8,2,4,5); quickSort
(0, count($a)-1);?>
PD9waHAKZnVuY3Rpb24gcXVpY2tTb3J0KCRzdGFydElELCRlbmRJRCkgewoJZ2xvYmFsICRhOwoJJHBpdm90ID0gJGFbKGludCkoKCRzdGFydElEICsgJGVuZElEKS8yKV07CgkkbGVmdCA9ICRzdGFydElEOwoJJHJpZ2h0ID0gJGVuZElEOwoJd2hpbGUgKHRydWUpIHsKCQl3aGlsZSAoJGFbJGxlZnRdIDwgJHBpdm90KSB7CgkJCSRsZWZ0Kys7CgkJfQoJCXdoaWxlICgkcGl2b3QgPCAkYVskcmlnaHRdKSB7CgkJCSRyaWdodC0tOwoJCX0KCQlpZiAoJHJpZ2h0IDw9JGxlZnQpIHsKCQkJYnJlYWs7CgkJfQoJCSR0bXAgPSAkYVskbGVmdF07CgkJJGFbJGxlZnRdID0gJGFbJHJpZ2h0XTsKCQkkYVskcmlnaHRdID0gJHRtcDsKCQkkbGVmdCsrOwoJfQoJaWYgKCRzdGFydElEIDwgJGxlZnQtMSkgewoJCXF1aWNrU29ydCgkcmlnaHQrMSwkZW5kSUQpOwoJfQp9CiRhID0gYXJyYXkoMTAsMywxLDksNyw2LDgsMiw0LDUpOwpxdWlja1NvcnQoMCwgY291bnQoJGEpLTEpOwpwcmludF9yKCRhKTsKPz4K