createSortByNaturalFn
Creates a sort function for objects by one or more string properties using natural ordering. Numbers embedded in values are compared numerically: “W2” < “W11” < “W20”. When multiple properties are given, ties on the first key are broken by the second key, then the third, and so on.
Available since v2.0.2
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
property | keyof T | readonly keyof T[] | The property (or ordered list of properties) to sort by. Defaults to trying ‘value’, ‘label’, ‘title’, ‘description’ in that order. (optional) |
caseInsensitive | boolean | Whether to ignore case and diacritics (default: false). Uses Intl.Collator { sensitivity: 'base' }, which treats é, E, and e as equal. This differs from createSortByStringFn(key, true), which only folds case and still distinguishes accented characters (é ≠ e). |
Returns
Section titled “Returns”SortFn<T> — Sort function
Examples
Section titled “Examples”createSortByNaturalFn
Section titled “createSortByNaturalFn”Related Types
Section titled “Related Types”SortFn
Section titled “SortFn”Sort function type for arrays
