sort package:containers

sort sorts the specified Seq 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 Seq according to the specified comparator. The sort is stable. If stability is not required, unstableSortBy can be slightly faster.
sortOn sorts the specified Seq 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 Seq 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.

WARNING

This module is considered internal. The Package Versioning Policy does not apply. The contents of this module may change in any way whatsoever and without any warning between minor versions of this package. Authors importing this module are expected to track development closely.

Description

This module provides the various sorting implementations for Data.Sequence. Further notes are available in the file sorting.md (in this directory).
Reverse ordering of topSort. See note in topSort.
A topological sort of the graph. The order is partially specified by the condition that a vertex i precedes j whenever j is reachable from i but not vice versa. Note: A topological sort exists only when there are no cycles in the graph. If the graph has cycles, the output of this function will not be a topological sort. In such a case consider using scc.
unstableSort sorts the specified Seq 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 Seq 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 Seq 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.