assoc-list-0.1.0.0: Association lists (lists of tuples)

Data.AssocList.List.Comparison

Contents

Description

Functions on AssocLists that make use of a Comparison on the keys.

Synopsis

# Related modules

A module that is a lot like this one:

• Data.AssocList.List.Ord - Functions on AssocLists that make use of an Ord constraint on the type of the keys

# Sorting

sortKeys :: Comparison a -> AssocList a b -> AssocList a b Source #

Sort an association list according to a particular Comparison of its keys. This is a stable sort, so when a key appears multiple times in the input list, the ordering of its values in the resulting list remains unchanged.

>>> sortKeys defaultComparison [(2, 'b'), (3, 'c'), (2, 'a'), (4, 'd'), (2, 'e'), (1, 'f')]
[(1,'f'),(2,'b'),(2,'a'),(2,'e'),(3,'c'),(4,'d')]