An Efficient way of Sorting Large Files on Disks: MergeSort
A solution for this problem was previously presented in the form of the Keysort algorithm. However, Keysort has two shortcomings:
- Once the key were sorted, it was expensive to seek each record in sorted order and then write them to the new, sorted file.
- If the file contains many records, even the index is too large to fit in memory.
Solution: (1) Break the file into several sorted subfiles (runs), using an internal sorting method; and (2) merge the runs. ==> MergeSort