sort package:nonempty-containers

sort sorts the specified NESeq by the natural ordering of its elements. The sort is stable. If stability is not required, unstableSort can be slightly faster.
sortBy sorts the specified NESeq according to the specified comparator. The sort is stable. If stability is not required, unstableSortBy can be slightly faster.
sortOn sorts the specified NESeq by comparing the results of a key function applied to each element. sortOn f is equivalent to sortBy (compare `on` f), but has the performance advantage of only evaluating f once for each element in the input list. This is called the decorate-sort-undecorate paradigm, or Schwartzian transform. An example of using sortOn might be to sort a NESeq of strings according to their length:
sortOn length (fromList ("alligator" :| ["monkey", "zebra"])) == fromList ("zebra" :| ["monkey", "alligator"])
If, instead, sortBy had been used, length would be evaluated on every comparison, giving <math> evaluations, rather than <math>. If f is very cheap (for example a record selector, or fst), sortBy (compare `on` f) will be faster than sortOn f.
CPP for new functions not in old containers --------------------------------------------- Compatibility layer for sortOn.
unstableSort sorts the specified NESeq by the natural ordering of its elements, but the sort is not stable. This algorithm is frequently faster and uses less memory than sort.
A generalization of unstableSort, unstableSortBy takes an arbitrary comparator and sorts the specified sequence. The sort is not stable. This algorithm is frequently faster and uses less memory than sortBy.
unstableSortOn sorts the specified NESeq by comparing the results of a key function applied to each element. unstableSortOn f is equivalent to unstableSortBy (compare `on` f), but has the performance advantage of only evaluating f once for each element in the input list. This is called the decorate-sort-undecorate paradigm, or Schwartzian transform. An example of using unstableSortOn might be to sort a NESeq of strings according to their length.
unstableSortOn length (fromList ("alligator" :| ["monkey", "zebra"])) == fromList ("zebra" :| ["monkey", "alligator]")
If, instead, unstableSortBy had been used, length would be evaluated on every comparison, giving <math> evaluations, rather than <math>. If f is very cheap (for example a record selector, or fst), unstableSortBy (compare `on` f) will be faster than unstableSortOn f.
Compatibility layer for unstableSortOn.