<?php
function quicksort($array)
{
if (count($array) == 0) {
return array();
}
$pivot = $array[0];
$left = $right = array();
foreach($array as $object){
if ($object < $pivot) {
$left[] = $object;
} else {
$right[] = $object;
}
}
return array_merge(quicksort($left), array($pivot), quicksort($right));
}
var_dump(quicksort([4, 10, 2, 6, 10, 1, 5]);
- Output for 5.4.0 - 5.4.24
- Parse error: syntax error, unexpected ';' in /in/jJlsI on line 23
Process exited with code 255. - Output for 5.3.0 - 5.3.28
- Parse error: syntax error, unexpected '[', expecting ')' in /in/jJlsI on line 23
Process exited with code 255.
preferences:
196.03 ms | 1395 KiB | 61 Q