Copyright | (c) 2010 John Millikin |
---|---|
License | BSD3 |
Maintainer | [email protected] |
Portability | portable |
Safe Haskell | Safe-Inferred |
Language | Haskell98 |
Algorithms.NaturalSort
Description
Human-friendly text collation
Synopsis
- data SortKey
- class NaturalSort a where
- sortKey :: a -> SortKey
- sortKeyCollated :: (Text -> ByteString) -> a -> SortKey
- compare :: NaturalSort a => a -> a -> Ordering
Documentation
class NaturalSort a where Source #
Methods
sortKey :: a -> SortKey Source #
Split a sortable type into textual and numeric sections, with no collation transformation.
If advanced collation is required, either pre-transform the input
(using eg toLower
) or use sortKeyCollated
.
sortKeyCollated :: (Text -> ByteString) -> a -> SortKey Source #
Split a sortable type into textual and numeric sections, using a custom collation transformation. This is useful for providing language- or use-specific ordering.
Instances
NaturalSort Text Source # | |
Defined in Algorithms.NaturalSort | |
NaturalSort Text Source # | |
Defined in Algorithms.NaturalSort | |
NaturalSort String Source # | |
Defined in Algorithms.NaturalSort |
compare :: NaturalSort a => a -> a -> Ordering Source #
Compare two values, using their natural ordering.