@SuppressWarnings({"unchecked","rawtypes"}) public static int partition(Object ar[],int left,int right,int pivotIndex,Comparator comparator){
  Object pivot=ar[pivotIndex];
  swap(ar,right,pivotIndex);
  int store=left;
  for (int idx=left; idx < right; idx++) {
    if (comparator.compare(ar[idx],pivot) <= 0) {
      swap(ar,idx,store);
      store++;
    }
  }
  swap(ar,right,store);
  return store;
}

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