In Wikibooks\' Haskell, there is the following claim:
Data.List offers a sort function for sorting lists. It does not use quicksort; rather, it uses an ef
I am not sure, but looking at the code i don't think Data.List.sort
is Mergesort as we know it. It just makes a single pass starting with the sequences
function in a beautiful triangular mutual recursive fashion with ascending
and descending
functions to result in a list of already ascending or descending ordered chunks in the required order. Only then it starts merging.
It's a manifestation of poetry in coding. Unlike Quicksort, its worst case (total random input) has O(nlogn) time complexity, and best case (already sorted ascending or descending) is O(n).
I don't think any other sorting algorithm can beat it.