presto-raptor-legacy/src/main/java/io/prestosql/plugin/raptor/legacy/util/PageBuffer.java/PageBuffer/appendSorted
class PageBuffer:    private void appendSorted()
    {
        long[] addresses = pageSorter.sort(columnTypes, pages, sortFields, sortOrders, toIntExact(rowCount));

        int[] pageIndex = new int[addresses.length];
        int[] positionIndex = new int[addresses.length];
        for (int i = 0; i < addresses.length; i++) {
            pageIndex[i] = pageSorter.decodePageIndex(addresses[i]);
            positionIndex[i] = pageSorter.decodePositionIndex(addresses[i]);
        }

        storagePageSink.appendPages(pages, pageIndex, positionIndex);
    }