question: public void sortFromTo ( int from , int to ) { final int widthThreshold = 10000 ; if ( size == 0 ) return ; checkRangeFromTo ( from , to , size ) ; int min = elements [ from ] ; int max = elements [ from ] ; int [ ] theElements = elements ; for ( int i = from + 1 ; i <= to ; ) { int elem = theElements [ i ++ ] ; if ( elem > max ) max = elem ; else if ( elem < min ) min = elem ; } double N = ( double ) to - ( double ) from + 1.0 ; double quickSortEstimate = N * Math . log ( N ) / 0.6931471805599453 ; double width = ( double ) max - ( double ) min + 1.0 ; double countSortEstimate = Math . max ( width , N ) ; if ( width < widthThreshold && countSortEstimate < quickSortEstimate ) { countSortFromTo ( from , to , min , max ) ; } else { quickSortFromTo ( from , to ) ; } }
target:  Sorts the specified range of the receiver into ascending order.  The sorting algorithm is dynamically chosen according to the characteristics of the data set. Currently quicksort and countsort are considered. Countsort is not always applicable, but if applicable, it usually outperforms quicksort by a factor of 3-4. <p>Best case performance: O(N). <dt>Worst case performance: O(N^2) (a degenerated quicksort). <dt>Best case space requirements: 0 KB.  <dt>Worst case space requirements: 40 KB.