public static < T extends Comparable < ? super T > > void insertionSort ( T [ ] arr , int start , int end ) { int i ; for ( int j = start + 1 ; j <= end ; j ++ ) { T tmp = arr [ j ] ; for ( i = j ; i > start && tmp . compareTo ( arr [ i - 1 ] ) < 0 ; i -- ) { arr [ i ] = arr [ i - 1 ] ; } if ( i < j ) arr [ i ] = tmp ; } }
method to sort an subarray from start to end with insertion sort algorithm