The typical external sorting [7] is a clustered sorting and
is a merge sort mechanism. Assume that we have B buffer
pages and the size of a record file is R pages. First, in pass 0,
read B pages long from the record file into the main memory
(i.e., B buffer pages) and sort them in main memory. After
sorting, the sorted content is written to flash memory and is
called a run. As a result, we will have ⌈R=B⌉ runs (except
the last run could contain fewer pages) and each run size is
B pages. In the following passes, B−1 buffer pages are used
as input buffer, where each buffer page has a corresponding
run. The remaining one buffer page is used as output buffer
and is written to flash memory while it is full. In each pass,
we can merge B−1 runs to a long run and the merge process
can be halted until the number of runs becomes one.