private static int quickSort0(int[] a, int low, int high, String tabs) { //the valid elements of the list are [low, high]
        if (high - low <= 1)
            return high - low;

        if (high - low == 2) { //efficient!
            if (a[low] > a[low + 1])
                swap(a, low, low + 1);

            return 1;
        }

        int n = high - low; //number of elements in the list.
        int p = pivot(a, low, high); //median of three; pivot's index.
        int pivot = a[p]; //p's value, the pivot value
        int i = low;
        int j = high - 2;
        swap(a, p, high - 1); //store the pivot at the end.

        while (i <= j) {
            while (a[i] < pivot && i < high - 2) { //don't run into the pivot we stored at index [high-1]
                i++;
            }

            while (a[j] > pivot && j > low) {
                j--;
            }

            if (i <= j) {
                swap(a, i, j);
                i++;
                j--;
            }
        }

        swap(a, i, high - 1); //put the pivot into its correct spot.

        printQuick(tabs, a, low, i, pivot, high);

        n += quickSort0(a, low, i, tabs + "    ");
        n += quickSort0(a, i + 1, high, tabs + "    ");

        return n;
    }