private static int partition(Comparable[] a, int lo, int hi){
        int i=lo, j=hi+1;

        while(true){
            //scan from left
            while( Helper.less(a[++i], a[lo]) ){
                if( i == hi )   break; //right bounds error check
            }
            //scan from right
            while( Helper.less(a[lo], a[--j]) ){
                if( j == lo )   break; //left bounds error check
            }

            if( i >= j ) break;  //bound check
            Helper.swap(a, i, j);
        }
        Helper.swap(a, j, lo); //put pivot elmt in the right index
        return j; //return index of pivot
    }