Skip to content

sortStringNaturalAscInsensitiveFn

Sort strings in ascending natural order, ignoring case and diacritics (Intl.Collator { sensitivity: 'base' } — treats é, E, and e as equal). Numbers embedded in strings are compared numerically: “W2” < “W11” < “W20”.

Available since v2.0.2

import { sortStringNaturalAscInsensitiveFn } from '@helpers4/array';
// or, from the all-in-one package (same code, one install):
import { sortStringNaturalAscInsensitiveFn } from 'helpers4/array';
['W11', 'W2', 'W20'].sort(sortStringNaturalAscInsensitiveFn) // => ['W2', 'W11', 'W20']

View source on GitHub