Mergesort
Merge sort is an O(n log n) worst-case comparison-based stable sorting algorithm.
Timsort
Timsort is a sorting algorithm invented by Tim Peters, designed to take advantage of partial ordering in data
Others
Example |
---|
Timsort is used by python and java for their sort methods and is rather supernaturally fast but it s a more complex algorithm than mergesort which matters if you re working in something like c - so if you just need something that works pretty well and is simple go with mergesort from question Sorting 2^30 number of 32 bit integers. Best solutions |
Rior java 8 that was not a big issue the sorting implementation mergesort would not throw exception;java8 changed default sorting implementation to timsort that is much more sensitive to comparators with invalid contract hence invalid contract might throw an exception from question Why does this code throw exception - Comparison method violates its general contract |