Almost implement external merge sort.