public static < T extends Comparable < ? super T > > void shellSort ( T [ ] arr ) { int j , k = 0 , gap ; for ( ; GAPS [ k ] < arr . length ; k ++ ) ; while ( k -- > 0 ) { gap = GAPS [ k ] ; for ( int i = gap ; i < arr . length ; i ++ ) { T tmp = arr [ i ] ; for ( j = i ; j >= gap && tmp . compareTo ( arr [ j - gap ] ) < 0 ; j -= gap ) { arr [ j ] = arr [ j - gap ] ; } if ( j < i ) arr [ j ] = tmp ; } } }
shell sort algorithm