TimSorter
Sorter implementation based on the TimSort algorithm. It sorts small arrays with a binary sort.
This algorithm is stable. It's especially good at sorting partially-sorted arrays.
NOTE:There are a few differences with the original implementation:
The extra amount of memory to perform merges is configurable. This allows small merges to be very fast while large merges will be performed in-place (slightly slower). You can make sure that the fast merge routine will always be used by having
maxTempSlotsequal to half of the length of the slice of data to sort.Only the fast merge routine can gallop (the one that doesn't run in-place) and it only gallops on the longest slice.
Properties
Functions
A binary sort implementation. This performs O(n*log(n)) comparisons and O(n^2) swaps. It is typically used by more sophisticated implementations as a fall-back when the number of items to sort has become less than {@value #BINARY_SORT_THRESHOLD}. This algorithm is stable.
Use heap sort to sort items between from inclusive and to exclusive. This runs in O(n*log(n)) and is used as a fall-back by IntroSorter. This algorithm is NOT stable.
Sorts between from (inclusive) and to (exclusive) with insertion sort. Runs in O(n^2). It is typically used by more sophisticated implementations as a fall-back when the number of items to sort becomes less than {@value #INSERTION_SORT_THRESHOLD}. This algorithm is stable.