Heap comparison based sorting question
Hint: Convert the input into $n/m &lt; m$ chunks of length $m$ and sort the chunks. Then use your heap idea. Note that you're using the assumption $m &gt; \sqrt{n}$ so that the heap fits in memory.