Safe Haskell | Safe |
---|---|

Language | Haskell2010 |

- sort :: Ord a => [a] -> [a]
- sortBy :: (a -> a -> Ordering) -> [a] -> [a]
- sortOn :: Ord b => (a -> b) -> [a] -> [a]
- monoidSortAssocs :: (Monoid a, Ord k) => [(k, a)] -> [(k, a)]
- monoidSortAssocsBy :: Monoid a => (k -> k -> Ordering) -> [(k, a)] -> [(k, a)]
- groupSortAssocs :: Ord k => (k -> a -> [a] -> b) -> [(k, a)] -> [(k, b)]
- groupSortAssocsBy :: (k -> k -> Ordering) -> (k -> a -> [a] -> b) -> [(k, a)] -> [(k, b)]
- monoidSort :: (Monoid a, Ord a) => [a] -> [a]
- monoidSortOn :: (Monoid a, Ord k) => (a -> k) -> [a] -> [a]
- monoidSortBy :: Monoid a => (a -> a -> Ordering) -> [a] -> [a]
- uniqueSort :: Ord a => [a] -> [a]
- uniqueSortOn :: Ord k => (a -> k) -> [a] -> [a]
- uniqueSortBy :: (a -> a -> Ordering) -> [a] -> [a]
- groupSort :: Ord a => (a -> [a] -> b) -> [a] -> [b]
- groupSortOn :: Ord k => (a -> k) -> (k -> a -> [a] -> b) -> [a] -> [b]
- groupSortBy :: (a -> a -> Ordering) -> (a -> [a] -> b) -> [a] -> [b]

# The Vanilla Sorts

sortOn :: Ord b => (a -> b) -> [a] -> [a] #

Sort a list by comparing the results of a key function applied to each
element. `sortOn f`

is equivalent to `sortBy (comparing 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.

*Since: 4.8.0.0*

# Sorting Associations

monoidSortAssocs :: (Monoid a, Ord k) => [(k, a)] -> [(k, a)] Source #

Sort the list of associations, aggregating duplicates with the monoid.

monoidSortAssocsBy :: Monoid a => (k -> k -> Ordering) -> [(k, a)] -> [(k, a)] Source #

Sort the list of associations, aggregating duplicates with the monoid and ordering the keys with the argument compare function.

groupSortAssocs :: Ord k => (k -> a -> [a] -> b) -> [(k, a)] -> [(k, b)] Source #

Sort the list of associations, aggregating duplicates with the supplied function.

groupSortAssocsBy :: (k -> k -> Ordering) -> (k -> a -> [a] -> b) -> [(k, a)] -> [(k, b)] Source #

Sort the list of associations, aggregating duplicates with the supplied function and ordering the keys with the argument compare function.

# Sorting with Monoids

monoidSort :: (Monoid a, Ord a) => [a] -> [a] Source #

Sort the list, agregating duplicates with the monoid.

monoidSortOn :: (Monoid a, Ord k) => (a -> k) -> [a] -> [a] Source #

Sort the list, agregating duplicates with the monoid and ordering the elements by the items generated by the argument function.

monoidSortBy :: Monoid a => (a -> a -> Ordering) -> [a] -> [a] Source #

Sort the list, agregating duplicates with the monoid and ordering the keys with the argument compare function.

# Unique Sorts

uniqueSort :: Ord a => [a] -> [a] Source #

Sort the list, discarding duplicates.

uniqueSortOn :: Ord k => (a -> k) -> [a] -> [a] Source #

Sort the list, discarding duplicates and ordering the elements by the items generated by the argument function.

uniqueSortBy :: (a -> a -> Ordering) -> [a] -> [a] Source #

Sort the list, discarding duplicates and ordering the keys with the argument compare function.

# Group Sorting

groupSort :: Ord a => (a -> [a] -> b) -> [a] -> [b] Source #

Sort a list of elements with a stable sort, grouping together the equal elements with the argument grouping function

groupSortOn :: Ord k => (a -> k) -> (k -> a -> [a] -> b) -> [a] -> [b] Source #

Sort a list of elements with a stable sort, using the argument
`compare`

function determine the ordering, grouping together the
equal elements with the grouping function

groupSortBy :: (a -> a -> Ordering) -> (a -> [a] -> b) -> [a] -> [b] Source #

Sort a list of elements with a stable sort, grouping together the equal elements with the argument grouping function.