When memory has been exhausted, we write the index of the block (which
consists of the dictionary and the postings lists) to disk (line 12). We have to
sort the terms (line 11) before doing this because we want to write postings
lists in lexicographic order to facilitate the final merging step. If each block’s
postings lists were written in unsorted order, merging blocks could not be
accomplished by a simple linear scan through each block.