The sort function implements a stable sorting algorithm. It is
a special case of sortBy, which allows the programmer to supply
their own comparison function.
Elements are arranged from lowest to highest, keeping duplicates in
the order they appeared in the input.
The nubOrd function removes duplicate elements
from a list. In particular, it keeps only the first occurrence of each
element. By using a Set internally it has better asymptotics
than the standard nub function.
Strictness
nubOrd is strict in the elements of the list.
Efficiency note
When applicable, it is almost always better to use nubInt or
nubIntOn instead of this function, although it can be a little
worse in certain pathological cases. For example, to nub a list of
characters, use
The sort function implements a stable sorting algorithm. It is
a special case of sortBy, which allows the programmer to supply
their own comparison function.
Elements are arranged from lowest to highest, keeping duplicates in
the order they appeared in the input.
On ordered lists, nub is equivalent to nub, except that
it runs in linear time instead of quadratic. On unordered lists it
also removes elements that are smaller than any preceding element.
The sort function implements a stable sorting algorithm. It is
a special case of sortBy, which allows the programmer to supply
their own comparison function.
The nubSort function is equivalent to nub.sort, except that duplicates are removed as it sorts. It
is essentially the same implementation as Data.List.sort,
with merge replaced by union. Thus the performance of
nubSort should better than or nearly equal to sort
alone. It is faster than both sort and nub.sort when the input contains significant quantities of
duplicated elements.