An Efficient Approach to Sorting in Memory
When we previously discussed sorting a file that is small enough to fit in memory, we assumed that:
- We would read the entire file from disk into memory.
- We would sort the records using a standard sorting procedure, such as shellsort.
- We would write the file back to disk.
If the file is read and written as efficiently as possible and if the best sorting algorithm is used, it seems that we cannot improve the efficiency of this procedure.
Nonetheless, we can improve it by doing things in parallel: we can do the reading or writing at the same time as the sorting.