Compare two strings with a natural alphabetic ordering (numbers sort properly).
Empty values sort last: "", null, and undefined last.
""
null
undefined
the first string to compare
the second string to compare
alphabetic ordering, with numbers sorted naturally
Error if string-natural-compare is not available
Sort strings with ascending numbers.
import { compareStringsNatural } from "@trashpanda001/helpers/comparators"compareStringsNatural("1 Dog", "2 Dogs")// -1 .. 1 Dog, 2 DogscompareStringsNatural("9 Cats", "8 Cats")// 1 ... 8 Cats, 9 Cats Copy
import { compareStringsNatural } from "@trashpanda001/helpers/comparators"compareStringsNatural("1 Dog", "2 Dogs")// -1 .. 1 Dog, 2 DogscompareStringsNatural("9 Cats", "8 Cats")// 1 ... 8 Cats, 9 Cats
Compare two strings with a natural alphabetic ordering (numbers sort properly).
Empty values sort last:
""
,null
, andundefined
last.