Compare two strings with an alphabetic ordering.
To sort strings with numbers in a human-friendly way, see compareStringsNatural. The empty values "", null, and undefined sort last.
compareStringsNatural
""
null
undefined
the first string to compare
the second string to compare
alphabetic ordering
Sort strings alphabetically.
import { compareStrings } from "@trashpanda001/helpers/comparators"compareStrings("a", "b")// -1 .. a, bcompareStrings("z", "y")// 1 ... y, z Copy
import { compareStrings } from "@trashpanda001/helpers/comparators"compareStrings("a", "b")// -1 .. a, bcompareStrings("z", "y")// 1 ... y, z
Compare two strings with an alphabetic ordering.
To sort strings with numbers in a human-friendly way, see
compareStringsNatural
. The empty values""
,null
, andundefined
sort last.