Table.SortFn

Generated from docs.json. 12 exposed values, types, and type aliases, in the order the module exposes them.

Built-in sort functions, ported from row-sorting/sortFns.ts.

A SortFn compares two cell values in ascending order. Descending order is applied by the sorted row model. Each sort fn carries an optional resolveDataValue normaliser that runs on both values before comparison, which is how the built-ins lowercase text or turn dates into timestamps.

Type

SortFn

type SortFn

An ascending comparison on cell values plus its value normaliser.

Built-ins

alphanumeric

alphanumeric : Table.SortFn.SortFn

Natural sort, case-insensitive: item2 before item10.

alphanumericCaseSensitive

alphanumericCaseSensitive : Table.SortFn.SortFn

Natural sort, case-sensitive.

text

text : Table.SortFn.SortFn

Plain lexicographic sort, case-insensitive.

textCaseSensitive

textCaseSensitive : Table.SortFn.SortFn

Plain lexicographic sort, case-sensitive.

datetime

datetime : Table.SortFn.SortFn

Chronological sort on Date values (and numeric timestamps).

Date values become millisecond timestamps first; anything else is compared with JavaScript's relational rules, so two strings compare as strings and everything else compares numerically.

basic

basic : Table.SortFn.SortFn

Direct comparison with no normalisation.

Building your own

custom

custom : (Table.Value.Value -> Table.Value.Value -> Order) -> Table.SortFn.SortFn

Build a sort fn from a comparison. Use withResolveDataValue to add a normaliser.

withResolveDataValue

withResolveDataValue : (Table.Value.Value -> Table.Value.Value) -> Table.SortFn.SortFn -> Table.SortFn.SortFn

Replace the normaliser that runs on both values before comparison.

Applying

compare

compare : Table.SortFn.SortFn -> Table.Value.Value -> Table.Value.Value -> Order

Compare two raw cell values: both are passed through the normaliser, then the comparison runs.

resolveDataValue

resolveDataValue : Table.SortFn.SortFn -> Table.Value.Value -> Table.Value.Value

Run only the normaliser.

Chunking

splitAlphaNumeric

splitAlphaNumeric : String -> List String

The Elm counterpart of splitting a string with TanStack's reSplitAlphaNumeric regex (/([0-9]+)/gm): runs of digits become their own segments, and the empty segments JavaScript leaves at the boundaries are kept.

splitAlphaNumeric "apple" == [ "apple" ]

splitAlphaNumeric "item10" == [ "item", "10", "" ]

splitAlphaNumeric "10abc" == [ "", "10", "abc" ]

splitAlphaNumeric "" == [ "" ]