Jump to content

Sorting algorithms/Bogosort: Difference between revisions

added php
No edit summary
(added php)
Line 402:
{my $k = int rand($n + 1);
@l[$k, $n] = @l[$n, $k] if $k != $n;}}</perl>
 
=={{header|PHP}}==
<php>function bogosort($l) {
while (!in_order($l))
shuffle($l);
return $l;
}
 
function in_order($l) {
for ($i = 1; $i < count($l); $i++)
if ($l[$i] < $l[$i-1])
return FALSE;
return TRUE;
}</php>
 
=={{header|Python}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.