code: public UnsafeSorterIterator getSortedIterator() throws IOException {
      assert(recordComparatorSupplier != null);
      if (spillWriters.isEmpty()) {
        assert(inMemSorter != null);
        readingIterator = new SpillableIterator(inMemSorter.getSortedIterator());
        return readingIterator;
      } else {
        final UnsafeSorterSpillMerger spillMerger = new UnsafeSorterSpillMerger(
          recordComparatorSupplier.get(), prefixComparator, spillWriters.size());
        for (UnsafeSorterSpillWriter spillWriter : spillWriters) {
          spillMerger.addSpillIfNotEmpty(spillWriter.getReader(serializerManager));
        }
        if (inMemSorter != null) {
          readingIterator = new SpillableIterator(inMemSorter.getSortedIterator());
          spillMerger.addSpillIfNotEmpty(readingIterator);
        }
        return spillMerger.getSortedIterator();
      }
    }
docs: Returns a sorted iterator. It is the caller's responsibility to call `cleanupResources()`
  after consuming this iterator.