Created
December 23, 2009 21:18
-
-
Save cweider/262812 to your computer and use it in GitHub Desktop.
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
import random | |
import itertools | |
def bongo_sort(numbers): | |
for (smaller, larger) in itertools.izip(numbers, itertools.islice(numbers, 1, None)): | |
if larger < smaller: | |
random.shuffle(numbers) | |
return bongo_sort(numbers) | |
numbers = [4, 3, 2, 1] | |
print numbers | |
bongo_sort(numbers) | |
print numbers | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment