Created
April 20, 2015 12:26
-
-
Save you-think-you-are-special/0fbc53857fd84d709887 to your computer and use it in GitHub Desktop.
Stupid sort example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function stupid_sort($array) | |
{ | |
$i = 0; | |
$n = count($array); | |
while ($i < $n - 1) { | |
if ($array[$i + 1] < $array[$i]) { | |
list($array[$i], $array[$i + 1]) = array($array[$i + 1], $array[$i]); | |
$i = 0; | |
} else $i++; | |
} | |
return $array; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment