1 MB Sorting Explained by Jeff Preshing.
From the post:
In my previous post, I shared some source code to sort one million 8-digit numbers in 1MB of RAM as an answer to this Stack Overflow question. The program works, but I didn’t explain how, leaving it as a kind of puzzle for the reader.
(image omitted)
I had promised to explain it in a followup post, and in the meantime, there’s been a flurry of discussion in the comments and on Reddit. In particular, commenter Ben Wilhelm (aka ZorbaTHut) already managed to explain most of it (Nice work!), and by now, I think quite a few people already get it. Nonetheless, I’ll write up another explanation as promised.
You may want to also review the answers and comments at Stack Overflow as well.
Sorting being one of those fundamental operations you will encounter time and again.
Even in topic maps.