@SuppressWarnings("empty-statement")
    private static <T extends Comparable<? super T>> void quickSort(T[] a, int low, int high) {

        if (low + CUTOFF >= high) {
            insertionSort(a, low, high);
        } else {
            int middle = (low + high) / 2;

            // Sort low, middle, high
            if (compare(a[middle], a[low]) < 0) {
                swapReferences(a, low, middle);
            }
            if (compare(a[high], a[low]) < 0) {
                swapReferences(a, low, high);
            }
            if (compare(a[high], a[middle]) < 0) {
                swapReferences(a, middle, high);
            }

            swapReferences(a, middle, high - 1);
            T pivot = a[high - 1];

            // Begin partitioning
            int i, j;
            for (i = low, j = high - 1;;) {
                // Start at position i+1 since low has already been sorted correctly
                // i.e. a[low] < pivot
                //while ( a[++i].compareTo(pivot) < 0 )
                while (compare(a[++i], pivot) < 0)
					;
                // Start at position j-1 since high has already been sorted correctly
                // i.e. a[high-1] = pivot
                //while ( a[--j].compareTo(pivot) > 0 )
                while (compare(a[--j], pivot) > 0)
					;
                if (i >= j) {
                    break;
                }
                swapReferences(a, i, j);
            }

            // Restore the pivot
            swapReferences(a, i, high - 1);

            quickSort(a, low, i - 1);   // Sort small elements 
            quickSort(a, i + 1, high);  // Sort large elements
        }

    }