public static void sort(SortProxy proxy,final long off,final long len){
  if (len < 7) {
    for (long i=off; i < len + off; i++) {
      for (long j=i; j > off && proxy.compare(j - 1,j) > 0; j--) {
        proxy.swap(j,j - 1);
      }
    }
    return;
  }
  long m=off + (len >> 1);
  if (len != 7) {
    long l=off;
    long n=off + len - 1;
    if (len > 40) {
      final long s=len / 8;
      l=med3(proxy,l,l + s,l + 2 * s);
      m=med3(proxy,m - s,m,m + s);
      n=med3(proxy,n - 2 * s,n - s,n);
    }
    m=med3(proxy,l,m,n);
  }
  long a=off;
  long b=a;
  long c=off + len - 1;
  long d=c;
  while (true) {
    int bcompm;
    while (b <= c && (bcompm=proxy.compare(b,m)) <= 0) {
      if (bcompm == 0) {
        proxy.swap(a++,b);
        if (b == m) {
          m=a - 1;
        }
      }
      b++;
    }
    int ccompm;
    while (c >= b && (ccompm=proxy.compare(c,m)) >= 0) {
      if (ccompm == 0) {
        proxy.swap(c,d--);
        if (c == m) {
          m=d + 1;
        }
      }
      c--;
    }
    if (b > c) {
      break;
    }
    proxy.swap(b++,c--);
  }
  long s2;
  final long n2=off + len;
  s2=Math.min(a - off,b - a);
  vecswap(proxy,off,b - s2,s2);
  s2=Math.min(d - c,n2 - d - 1);
  vecswap(proxy,b,n2 - s2,s2);
  if ((s2=b - a) > 1) {
    sort(proxy,off,s2);
  }
  if ((s2=d - c) > 1) {
    sort(proxy,n2 - s2,s2);
  }
}

public static void sort ( SortProxy proxy , final long off , final long len ) { if ( len < 7 ) { for ( long i = off ; i < len + off ; i ++ ) { for ( long j = i ; j > off && proxy . compare ( j - 1 , j ) > 0 ; j -- ) { proxy . swap ( j , j - 1 ) ; } } return ; } long m = off + ( len > > 1 ) ; if ( len != 7 ) { long l = off ; long n = off + len - 1 ; if ( len > 40 ) { final long s = len / 8 ; l = med3 ( proxy , l , l + s , l + 2 * s ) ; m = med3 ( proxy , m - s , m , m + s ) ; n = med3 ( proxy , n - 2 * s , n - s , n ) ; } m = med3 ( proxy , l , m , n ) ; } long a = off ; long b = a ; long c = off + len - 1 ; long d = c ; while ( true ) { int bcompm ; while ( b <= c && ( bcompm = proxy . compare ( b , m ) ) <= 0 ) { if ( bcompm == 0 ) { proxy . swap ( a ++ , b ) ; if ( b == m ) { m = a - 1 ; } } b ++ ; } int ccompm ; while ( c >= b && ( ccompm = proxy . compare ( c , m ) ) >= 0 ) { if ( ccompm == 0 ) { proxy . swap ( c , d -- ) ; if ( c == m ) { m = d + 1 ; } } c -- ; } if ( b > c ) { break ; } proxy . swap ( b ++ , c -- ) ; } long s2 ; final long n2 = off + len ; s2 = Math . min ( a - off , b - a ) ; vecswap ( proxy , off , b - s2 , s2 ) ; s2 = Math . min ( d - c , n2 - d - 1 ) ; vecswap ( proxy , b , n2 - s2 , s2 ) ; if ( ( s2 = b - a ) > 1 ) { sort ( proxy , off , s2 ) ; } if ( ( s2 = d - c ) > 1 ) { sort ( proxy , n2 - s2 , s2 ) ; } }
sorts the specified sub - collection of items through a proxy
