private static int  partition(Comparable[] array, int low, int high) {
        int i = low;
        int j = high + 1;
        Comparable element = array[low];

        while(true) {
            while(array[++i].compareTo(element) < 0) {
                if(i == high) break;
            }
            while(element.compareTo(array[--j]) < 0) {
                if(j == low)  break;
            }

            if(i >= j) {
                break;
            }
            exchange(array, i, j);
        }

        exchange(array, low, j);
        return j;
    }