private static void insertionSort ( int [ ] data , final int start , final int end , IntComparator comp ) { // Classic insertion sort. for ( int i = start + 1 ; i < end ; i ++ ) { final int cur = data [ i ] ; int j = i - 1 ; while ( j >= start ) { final int pre = data [ j ] ; if ( comp . compare ( cur , pre ) >= 0 ) { break ; } data [ j + 1 ] = pre ; -- j ; } data [ j + 1 ] = cur ; } }
Insertion sort for short arrays .