Bongo Sort

by Chad Weider on December 18th, 2009
No notes
Syntax: Python
Show lines - Hide lines - Show in textbox - Download
def bongo_sort(numbers):
    if any((larger < smaller for (smaller, larger) in itertools.izip(numbers, itertools.islice(numbers, 1, None)))):
	random.shuffle(numbers)
        bongo_sort(numbers)
 
numbers = [4, 3, 2, 1]
print numbers
bongo_sort(numbers)
print numbers
 

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS