Sorting algorithms/Bogosort: Difference between revisions

Content deleted Content added
No edit summary
added php
Line 402: Line 402:
{my $k = int rand($n + 1);
{my $k = int rand($n + 1);
@l[$k, $n] = @l[$n, $k] if $k != $n;}}</perl>
@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}}==
=={{header|Python}}==