private void quickSortMostly0(int[] a, int low, int high) { //the valid elements of the list are [low, high]
        if (high - low <= a.length / 10)
            return;

        int n = high - low; //number of elements in the list.
        int p = low + 1; //median of three; pivot's index.
        int pivot = a[p]; //p's value, the pivot value
        int i = low;
        int j = high - 2;
        initializeReversed();
        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.

        quickSortMostly0(a, low, i);
        quickSortMostly0(a, i + 1, high);
    }