public int partition(int left,int right,int pivotIndex){
  E pivot=ar[pivotIndex];
  E tmp=ar[right];
  ar[right]=ar[pivotIndex];
  ar[pivotIndex]=tmp;
  int store=left;
  for (int idx=left; idx < right; idx++) {
    if (comparator.compare(ar[idx],pivot) <= 0) {
      tmp=ar[idx];
      ar[idx]=ar[store];
      ar[store]=tmp;
      store++;
    }
  }
  tmp=ar[right];
  ar[right]=ar[store];
  ar[store]=tmp;
  return store;
}

public int partition ( int left , int right , int pivotIndex ) { E pivot = ar [ pivotIndex ] ; E tmp = ar [ right ] ; ar [ right ] = ar [ pivotIndex ] ; ar [ pivotIndex ] = tmp ; int store = left ; for ( int idx = left ; idx < right ; idx ++ ) { if ( comparator . compare ( ar [ idx ] , pivot ) <= 0 ) { tmp = ar [ idx ] ; ar [ idx ] = ar [ store ] ; ar [ store ] = tmp ; store ++ ; } } tmp = ar [ right ] ; ar [ right ] = ar [ store ] ; ar [ store ] = tmp ; return store ; }
in linear time , group an array into two parts , those less than or equal to a certain value ( left ) , and those greater than a certain value ( right ) .
