private static void quickSort1(Object x[],int off,int len,Comparator comp){
  if (len < SMALL) {
    for (int i=off; i < len + off; i++)     for (int j=i; j > off && comp.compare(x[j - 1],x[j]) > 0; j--)     swap(x,j,j - 1);
    return;
  }
  int m=off + len / 2;
  if (len > SMALL) {
    int l=off;
    int n=off + len - 1;
    if (len > MEDIUM) {
      int s=len / 8;
      l=med3(x,l,l + s,l + 2 * s,comp);
      m=med3(x,m - s,m,m + s,comp);
      n=med3(x,n - 2 * s,n - s,n,comp);
    }
    m=med3(x,l,m,n,comp);
  }
  Object v=x[m];
  int a=off, b=a, c=off + len - 1, d=c;
  while (true) {
    int comparison;
    while (b <= c && (comparison=comp.compare(x[b],v)) <= 0) {
      if (comparison == 0)       swap(x,a++,b);
      b++;
    }
    while (c >= b && (comparison=comp.compare(x[c],v)) >= 0) {
      if (comparison == 0)       swap(x,c,d--);
      c--;
    }
    if (b > c)     break;
    swap(x,b++,c--);
  }
  int s, n=off + len;
  s=Math.min(a - off,b - a);
  vecswap(x,off,b - s,s);
  s=Math.min(d - c,n - d - 1);
  vecswap(x,b,n - s,s);
  if ((s=b - a) > 1)   quickSort1(x,off,s,comp);
  if ((s=d - c) > 1)   quickSort1(x,n - s,s,comp);
}

private static void quickSort1 ( Object x [ ] , int off , int len , Comparator comp ) { if ( len < SMALL ) { for ( int i = off ; i < len + off ; i ++ ) for ( int j = i ; j > off && comp . compare ( x [ j - 1 ] , x [ j ] ) > 0 ; j -- ) swap ( x , j , j - 1 ) ; return ; } int m = off + len / 2 ; if ( len > SMALL ) { int l = off ; int n = off + len - 1 ; if ( len > MEDIUM ) { int s = len / 8 ; l = med3 ( x , l , l + s , l + 2 * s , comp ) ; m = med3 ( x , m - s , m , m + s , comp ) ; n = med3 ( x , n - 2 * s , n - s , n , comp ) ; } m = med3 ( x , l , m , n , comp ) ; } Object v = x [ m ] ; int a = off , b = a , c = off + len - 1 , d = c ; while ( true ) { int comparison ; while ( b <= c && ( comparison = comp . compare ( x [ b ] , v ) ) <= 0 ) { if ( comparison == 0 ) swap ( x , a ++ , b ) ; b ++ ; } while ( c >= b && ( comparison = comp . compare ( x [ c ] , v ) ) >= 0 ) { if ( comparison == 0 ) swap ( x , c , d -- ) ; c -- ; } if ( b > c ) break ; swap ( x , b ++ , c -- ) ; } int s , n = off + len ; s = Math . min ( a - off , b - a ) ; vecswap ( x , off , b - s , s ) ; s = Math . min ( d - c , n - d - 1 ) ; vecswap ( x , b , n - s , s ) ; if ( ( s = b - a ) > 1 ) quickSort1 ( x , off , s , comp ) ; if ( ( s = d - c ) > 1 ) quickSort1 ( x , n - s , s , comp ) ; }
sorts the specified sub - array of chars into ascending order .
