Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

The Best Sorting Algorithm

Name: Anonymous 2009-09-07 21:49

In this thread we will discuss sorting algorithms and vote for our favorite one.

I will update the stats every postIndex % 25 posts.  

May the best #sort win!

- Bubble Sort
- Insertion Sort
- Selection Sort
- Merge Sort
- Quick Sort
- Heap Sort
- Shell Sort
- Bucket Sort
- Radix Sort


Vote for one of these or any sort you like. I'll add new sorts to the list when I update stats.

Name: Anonymous 2009-09-08 16:53


from random import shuffle
 
def bogo_sort(seq):
    count = 0
    while not all(x <= y for x, y in zip(seq, seq[1:])):
        shuffle(seq)
        count+=1
    print seq,'in',count



>>> bogo_sort([1,6,9,3,2,87])
[1, 2, 3, 6, 9, 87] in 900
>>> bogo_sort([1,6,9,3,2,87])
[1, 2, 3, 6, 9, 87] in 172
[b]>>> bogo_sort([1,6,9,3,2,87])
[1, 2, 3, 6, 9, 87] in 2[/b]
>>> bogo_sort([1,6,9,3,2,87])
[1, 2, 3, 6, 9, 87] in 868


IT'S LIKE THE BEST SORTING ALGORITHM EVAR

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List