private void removingDupesAndSort() { // duplicated ids can be present for some index due to cancellation of indexing for next index
    final int[] currentChanges = changes;
    final int intLength = length;

    if (intLength <
        250) { // Plain sorting in Arrays works without allocations for small number of elements (see DualPivotQuicksort.QUICKSORT_THRESHOLD)
      Arrays.sort(currentChanges, 0, intLength);
      boolean hasDupes = false;

      for (int i = 0, max = intLength - 1; i < max; ++i) {
        if (currentChanges[i] == currentChanges[i + 1]) {
          hasDupes = true;
          break;
        }
      }

      if (hasDupes) {
        int ptr = 0;
        for (int i = 1; i < intLength; ++i) {
          if (currentChanges[i] != currentChanges[ptr]) {
            currentChanges[++ptr] = currentChanges[i];
          }
        }
        length = (short)(ptr + 1);
      }
    }
    else {
      ValueContainer.IntIterator sorted =
        SortedFileIdSetIterator.getTransientIterator(new ChangesIterator(currentChanges, length, false));
      int lastIndex = 0;
      while (sorted.hasNext()) {
        currentChanges[lastIndex++] = sorted.next();
      }

      length = (short)lastIndex;
    }
    mayHaveDupes = false;

    if (intLength != 0 && length == 0) {
      throw new AssertionError("ids list is empty after sorting and duplicates elimination");
    }
  }
private void removingDupesAndSort()