code: private static void partialSort(
        final WordIterator[] a,
        final int maxChangedIndex,
        final int size,
        final Comparator<WordIterator> comp
    )
    {
      for (int i = maxChangedIndex; i >= 0; i--) {
        WordIterator it = a[i];
        for (int j = i + 1; j < size; j++) {
          WordIterator it2 = a[j];
          if (comp.compare(it, it2) <= 0) {
            break;
          }
          a[j - 1] = it2;
          a[j] = it;
        }
      }
    }
docs: Variation of insertion sort, elements [maxChangedIndex + 1, size) are sorted, elements [0, maxChangedIndex] should
  be inserted into that sorted range.