Of course this is a n^2 sort. Combinatorial Algorithms by Nijenhuis and Wilf, 1975, has a 23 lines Fortran implementation of Heapsort, a n log n sort. It is available on the web and easily found, so I am going to list it here. I am not going to attempt to convert it to C.
Note: Enjoy discriminating between the one and the lower-case l.
Isn't it exponential? An n element sort calls two n-1 element sorts. Each of those calls two n-2 element sorts, and so on. So you get 2^n total calls, if I'm not mistaken. That is also why the page asks if you can beat it with a function of equal length but subexponential runtime.
Think of this comment what you will, but to me that is some beautiful code. I love the conciseness. Snobol is a bit like that, too. Languages today tend to be relatively verbose, but certainly not as economic nor efficient.
Technically they aren’t numbered, they have a label. Labels serve as jump targets, have to appear in columns 1-5, must be numeric and all different, and should appear in order, but I don’t think they must.
Those are both from before the final, 56-byte version was added, though I expect they probably prompted / were prompted by the addition of steps 12–19.
That would (kind of) be the Kolmogorov complexity[1] (only kind of - the Kolmogorov complexity is actually the shortest program that produces a single output, rather than the shortest program that implements an algorithm). In any case the search space is still vast: making some assumptions about the number of bits in a character of C source code, you'd be searching something like 2^(6*60) bits, a number with about 108 decimal digits. We're in "longer than the lifetime of the universe" territory here. It might be better to search C ASTs instead, although the numbers are still going to be huge.
The general field of endeavour for searching binary programs is called superoptimization[2] and people really do it for very small program fragments.
I thought about this more than I probably should have, and I'm fairly sure you can't pull off a C sleep sort that sorts in place and is nearly as compact as the programs in the article.
So is the exponential one in the featured article. But both do sort. If you could get a sleep sort shorter than that, that would be a nice achievement. Though I guess your original post was just a bad joke, oh well.
Note: Enjoy discriminating between the one and the lower-case l.