public static void sort(final CommonIndex x,final long off,final long len,final Swapper swapper){
  if (len < 7) {
    for (long i=off; i < len + off; i++) {
      for (long j=i; j > off && x.get(j - 1) > x.get(j); j--) {
        swapper.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(x,l,l + s,l + 2 * s);
      m=med3(x,m - s,m,m + s);
      n=med3(x,n - 2 * s,n - s,n);
    }
    m=med3(x,l,m,n);
  }
  final long v=x.get(m);
  long a=off;
  long b=a;
  long c=off + len - 1;
  long d=c;
  while (true) {
    while (b <= c && x.get(b) <= v) {
      if (x.get(b) == v) {
        swapper.swap(a++,b);
      }
      b++;
    }
    while (c >= b && x.get(c) >= v) {
      if (x.get(c) == v) {
        swapper.swap(c,d--);
      }
      c--;
    }
    if (b > c) {
      break;
    }
    swapper.swap(b++,c--);
  }
  long s2;
  final long n2=off + len;
  s2=Math.min(a - off,b - a);
  vecswap(swapper,off,b - s2,s2);
  s2=Math.min(d - c,n2 - d - 1);
  vecswap(swapper,b,n2 - s2,s2);
  if ((s2=b - a) > 1) {
    sort(x,off,s2,swapper);
  }
  if ((s2=d - c) > 1) {
    sort(x,n2 - s2,s2,swapper);
  }
}

public static void sort ( final CommonIndex x , final long off , final long len , final Swapper swapper ) { if ( len < 7 ) { for ( long i = off ; i < len + off ; i ++ ) { for ( long j = i ; j > off && x . get ( j - 1 ) > x . get ( j ) ; j -- ) { swapper . 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 ( x , l , l + s , l + 2 * s ) ; m = med3 ( x , m - s , m , m + s ) ; n = med3 ( x , n - 2 * s , n - s , n ) ; } m = med3 ( x , l , m , n ) ; } final long v = x . get ( m ) ; long a = off ; long b = a ; long c = off + len - 1 ; long d = c ; while ( true ) { while ( b <= c && x . get ( b ) <= v ) { if ( x . get ( b ) == v ) { swapper . swap ( a ++ , b ) ; } b ++ ; } while ( c >= b && x . get ( c ) >= v ) { if ( x . get ( c ) == v ) { swapper . swap ( c , d -- ) ; } c -- ; } if ( b > c ) { break ; } swapper . swap ( b ++ , c -- ) ; } long s2 ; final long n2 = off + len ; s2 = Math . min ( a - off , b - a ) ; vecswap ( swapper , off , b - s2 , s2 ) ; s2 = Math . min ( d - c , n2 - d - 1 ) ; vecswap ( swapper , b , n2 - s2 , s2 ) ; if ( ( s2 = b - a ) > 1 ) { sort ( x , off , s2 , swapper ) ; } if ( ( s2 = d - c ) > 1 ) { sort ( x , n2 - s2 , s2 , swapper ) ; } }
sorts the specified sub - array of integers into ascending order . a modified version of the jdk sort to handle three arrays .
