In the realm of sorting algorithms, usually a O(n log n) algorithm is considered a "good algorithm", and a O(n²) one is considered a "bad algorithm". However, there does exist a sorting algorithm that is even worse: bogo sort is O(n!). (Note, however, that bogo sort is a joke. It was deliberately designed to be as bad as possible.)
The algorithm is simple:
Here it is:
And here it is on a longer data set: Do not expect these to finish. Ever.Of course, if we make the size small enough, we can see it actually complete:
It is not adaptive:
It is not stable:
In fact, there is absolutely no reason to use this algorithm, save for demonstrating how bad and wasteful factorial algorithms are.
On to the conclusions...