Data.Sort

Synopsis

# The Vanilla Sorts

sort :: Ord a => [a] -> [a] #

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.

sortBy :: (a -> a -> Ordering) -> [a] -> [a] #

The sortBy function is the non-overloaded version of sort.

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 #

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.