(From here)
I attended an interview last week and this question was asked:
How do you sort a billion rows of data in a file with only 640KB of memory in
The more I think about this, the more I think merge sort would work very well within the memory window we're given.
Let's say you have x memory available. Divide the billion entries into billion/x + 1 sections and heapsort them (heapsort because no extra memory is required and it's O(2n(log n)) time). When all sections are heapsorted, do a merge sort starting across the first elements of all sections. This will work so long as you have more than sqrt(billion) memory to work with given basic 8080 OS memory usage.
Doing the math, this assumes that each data row is less than 165 bits.