Very possibly the world's worst sorting algorithm, copyright 2001 by Adam M. Briska.

The algorithm is pretty intuitive: plow through all possible permutations of the list until you find the one that is sorted. In general, running this on any list larger than about 10-13 elements (depending on your system) will become painfully slow.

On a 700 MHz machine, sorting a list of 10 elements takes about 10 seconds of cpu time. From there, time complexities grow with the factorial of the list size for the average and worst case scenarios.

NOTE: a best-case scenario (ie, the list is sorted) results in an order N evaluation, which is better than the quicksort algorithm.

In general, when I describe this algorithm to people, they suggest that a worse algorithm would be to just randomize the list over and over again until it is sorted. I object to this from an algorithmic purity standpoint. It is my bias than an algorithm should proceed steadily towards a solution, which the randomization scheme does not do, unless you eliminate each possibility after each iteration, at which point it simply becomes the permutation sort.

USE: The interface is intended to ressemble exactly the interface to the standard c function of qsort, to allow easy insertion of this code into applications that you want to make unuseable.

[The Code]

[Back]