Hacker News new | ask | show | jobs
by michaelcampbell 5520 days ago
I always liked the sort where you randomize the elements, check to see if they're sorted, and if not try again.
3 comments

My personal favorite has always been permutation sort, where you try all possible permutations of a sequence and check if it is sorted.

What's nice about it is that it is deterministic yet ridiculously slow.

It can also be really easily implemented in Prolog[1] where you simply define what a permutation and being sorted means. After that you just search for a sorted permutation.

[1] http://rosettacode.org/wiki/Sorting_algorithms/Permutation_s...

Yeah, I recalled the name as random sort, and was pleasantly surprised when the bogosort link directed to the same algorithm. I particularly enjoyed the "Quantum Bogosort" algorithm on the Wiki page.

http://en.wikipedia.org/wiki/Bogosort#Quantum_bogosort

If you enjoyed that you might like the novel Quarantine by Greg Egan:

http://en.wikipedia.org/wiki/Quarantine_%28Greg_Egan_novel%2...

I never understood why Bogosort made the check so efficient; it seems so silly. Fortunately, somebody solved this problem and made bogobogosort: http://www.dangermouse.net/esoteric/bogobogosort.html