Flashsort
en.wikipedia.org
en.wikipedia.org
I suppose you could pick the bounds by sampling: pick m random elements, sort them, and use those as the upper bounds. Better yet, pick km random elements, sort them, and use every k'th one as an upper bound. But the author's intention is that the number of classes is a (large!) fraction of the number of elements, so this would give you O(n log n) overall complexity, missing the point entirely.
I note that the classification algorithm, if run on already-sorted input, puts the classes in reverse order. If the classes are small, this doesn't matter, but if they were bigger, it would be worth using the TimSort trick of checking for runs of increasing elements and just flipping them.
I also note that this algorithm involves making three passes over the data: one to count the number of elements in each class, one to classify elements (this pass involves random access), and another to sort the classes. No worse than quicksort, but not ideal for an external sort, and maybe not too cache-friendly.
I made some experiments with samplesort, and found with Java it can be about 40% faster than Arrays.sort, and for C++ maybe 5-10% faster: https://github.com/thomasmueller/fastSort_java and https://github.com/thomasmueller/fastSort_cpp
Historic footnote: samplesort was the Python sort algorithm before it was replaced with Timsort: https://bugs.python.org/issue587076 (specially see the attached timsort.txt)
My latter two examples weren't even in order, I was just recalling my impression.
Bucket by suit, sort each suit.
I think you're misunderstanding Paperweight's post and/or the idea behind flashsort. Hashes are uniformly distributed, hence you can use flashsort (instead of mergesort, quicksort, etc.) and get a time complexity of O(n) instead of O(N*log(N)).
However, my first thoughts it does seem (from its concept) not so easy to implement(?). Additionally I would have concerns with regards to how much an overhead this calculation adds compared to just a “simple” comparison.
Maybe the calculation is worth it if the comparison is costly enough? My guess would at least be that we would need fewer comparisons in Flashsort as we should have a higher chance of “knowing” where things should go.
The Wikipedia article shares no plots/data (guess I should dig deeper for that), but would be interesting to see how well it fares against more modern and/or optimized versions or Quicksort as it is unclear if the claim that it becomes faster than Quicksort is correct :)
[0] https://www.drdobbs.com/database/the-flashsort1-algorithm/18...