private static < E extends Comparable < E > > void sort ( List < E > list , int start , int end , boolean descending ) { if ( start == end ) { return ; } int middle = ( start + end ) >> 1 ; Merge . sort ( list , start , middle , descending ) ; Merge . sort ( list , middle + 1 , end , descending ) ; if ( descending ) { Merge . mergeDescending ( list , start , middle , end ) ; } else { Merge . merge ( list , start , middle , end ) ; } }
Sort routine that recursively calls itself after splitting the original list in half . This routine is used for both ascending and descending sort since the work done is similar . The only difference is when calling the merge routine .