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 nubBy function is the greedy algorithm that returns a
sublist of its input such that:
isSortedBy pred (nubBy pred xs) == True
This is true for all lists, not just ordered lists, and all binary
predicates, not just total orders. On infinite lists, this statement
is true in a certain mathematical sense, but not a computational one.
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.