@SuppressWarnings("checkstyle:InnerAssignment")
  public static void quickSort(
      final int[][] x, final long from, final long to, final IntComparator comp) {
    final long len = to - from;
    // Selection sort on smallest arrays
    if (len < SMALL) {
      selectionSort(x, from, to, comp);
      return;
    }
    // Choose a partition element, v
    long m = from + len / 2; // Small arrays, middle element
    if (len > SMALL) {
      long l = from;
      long n = to - 1;
      if (len > MEDIUM) { // Big arrays, pseudomedian of 9
        long s = len / 8;
        l = med3(x, l, l + s, l + 2 * s, comp);
        m = med3(x, m - s, m, m + s, comp);
        n = med3(x, n - 2 * s, n - s, n, comp);
      }
      m = med3(x, l, m, n, comp); // Mid-size, med of 3
    }
    final int v = get(x, m);
    // Establish Invariant: v* (<v)* (>v)* v*
    long a = from;
    long b = a;
    long c = to - 1;
    long d = c;
    while (true) {
      int comparison;
      while (b <= c && (comparison = comp.compare(get(x, b), v)) <= 0) {
        if (comparison == 0) {
          swap(x, a++, b);
        }
        b++;
      }
      while (c >= b && (comparison = comp.compare(get(x, c), v)) >= 0) {
        if (comparison == 0) {
          swap(x, c, d--);
        }
        c--;
      }
      if (b > c) {
        break;
      }
      swap(x, b++, c--);
    }
    // Swap partition elements back to middle
    long s;
    long n = to;
    s = Math.min(a - from, b - a);
    vecSwap(x, from, b - s, s);
    s = Math.min(d - c, n - d - 1);
    vecSwap(x, b, n - s, s);
    // Recursively sort non-partition-elements
    if ((s = b - a) > 1) {
      quickSort(x, from, from + s, comp);
    }
    if ((s = d - c) > 1) {
      quickSort(x, n - s, n, comp);
    }
  }
Sorts the specified range of elements according to the order induced by the specified
comparator using quicksort.

<p>

<p>The sorting algorithm is a tuned quicksort adapted from Jon L. Bentley and M. Douglas
McIlroy, &ldquo;Engineering a Sort Function&rdquo;, <i>Software: Practice and Experience</i>,
23(11), pages 1249&minus;1265, 1993.

@param x the big array to be sorted.
@param from the index of the first element (inclusive) to be sorted.
@param to the index of the last element (exclusive) to be sorted.
@param comp the comparator to determine the sorting order.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/aggregation/grouped/array/IntBigArrays.java