@Contract(mutates = "param1")
  public static <T> void sort(T @NotNull [] array, @NotNull Comparator<? super T> comparator) {
    int size = array.length;

    if (size < 2) return;
    if (size == 2) {
      T t0 = array[0];
      T t1 = array[1];

      if (comparator.compare(t0, t1) > 0) {
        array[0] = t1;
        array[1] = t0;
      }
    }
    else if (size < INSERTION_SORT_THRESHOLD) {
      for (int i = 0; i < size; i++) {
        for (int j = 0; j < i; j++) {
          T ti = array[i];
          T tj = array[j];

          if (comparator.compare(ti, tj) < 0) {
            array[i] = tj;
            array[j] = ti;
          }
        }
      }
    }
    else {
      Arrays.sort(array, comparator);
    }
  }
@Contract(mutates = "param1")
  public static <T> void sort(T @NotNull [] array, @NotNull Comparator<? super T> comparator)