code: public UnsafeSorterIterator getSortedIterator() {
      int offset = 0;
      long start = System.nanoTime();
      if (sortComparator != null) {
        if (this.radixSortSupport != null) {
          offset = RadixSort.sortKeyPrefixArray(
            array, nullBoundaryPos, (pos - nullBoundaryPos) / 2L, 0, 7,
            radixSortSupport.sortDescending(), radixSortSupport.sortSigned());
        } else {
          MemoryBlock unused = new MemoryBlock(
            array.getBaseObject(),
            array.getBaseOffset() + pos * 8L,
            (array.size() - pos) * 8L);
          LongArray buffer = new LongArray(unused);
          Sorter<RecordPointerAndKeyPrefix, LongArray> sorter =
            new Sorter<>(new UnsafeSortDataFormat(buffer));
          sorter.sort(array, 0, pos / 2, sortComparator);
        }
      }
      totalSortTimeNanos += System.nanoTime() - start;
      if (nullBoundaryPos > 0) {
        assert radixSortSupport != null : "Nulls are only stored separately with radix sort";
        LinkedList<UnsafeSorterIterator> queue = new LinkedList<>();
  
        // The null order is either LAST or FIRST, regardless of sorting direction (ASC|DESC)
        if (radixSortSupport.nullsFirst()) {
          queue.add(new SortedIterator(nullBoundaryPos / 2, 0));
          queue.add(new SortedIterator((pos - nullBoundaryPos) / 2, offset));
        } else {
          queue.add(new SortedIterator((pos - nullBoundaryPos) / 2, offset));
          queue.add(new SortedIterator(nullBoundaryPos / 2, 0));
        }
        return new UnsafeExternalSorter.ChainedIterator(queue);
      } else {
        return new SortedIterator(pos / 2, offset);
      }
    }
docs: Return an iterator over record pointers in sorted order. For efficiency, all calls to
  {@code next()} will return the same mutable object.