NaturalSort-0.2.1: Natural sorting for strings

Portabilityunportable
Stabilityunstable
Maintainerjoachim.fasting@gmail.com

Chunk

Description

Break textual input into sortable chunks.

Synopsis

Documentation

type Chunk = Either Int ByteStringSource

A chunk is either a pure integral value, or a string that might contain digits, letters and other characters.

When preparing strings for natural comparison, they are first broken into several chunks, which can then be compared and ordered "naturally".

toChunks :: ByteString -> [Chunk]Source

Turn a string into a list of Chunks.

 toChunks "a12x.txt" = [S "a", N 12, S "x.txt"]
 toChunks "7" `compare` toChunks "10" = LT
 toChunks "a7.txt" `compare` toChunks "a10.txt" = LT
 toChunks "7a.txt" `compare` toChunks "10a.txt" = LT