Skip to content

sortStringNaturalDescFn

Sort strings in descending order using natural (human-friendly) ordering. Numbers embedded in strings are compared numerically: “W20” > “W11” > “W2”.

Available since v2.0.2

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

View source on GitHub