Skip to content

alphanumericCompare

Function which, given two strings, the type of comparison to be verified, and optional options, performs the comparison between the two strings and returns a boolean indicating whether the indicated comparison is respected or not.

Types

AlphanumericCompareProps

Parameters accepted by all overloads of alphanumericCompare.

PropertyTypeRequiredDescription
string1stringThe first string to compare.
string2stringThe second string to compare.
compareType"<" \| ">" \| "=" \| ">=" \| "<="Controls the return type and comparison mode: - undefined (default) — Returns a numeric sort order value (-1, 0, or 1), following the same semantics as Intl.Collator.prototype.compare. - "&lt;" | "&gt;" | "=" | "&gt;=" | "&lt;=" — Returns a boolean indicating whether the comparison satisfies the given operator.
localesIntl.LocalesArgumentA BCP 47 language tag or array of tags forwarded to Intl.Collator. Determines locale-sensitive string ordering rules (e.g. "en", "de", "it"). When omitted, the runtime default locale is used.
optsIntl.CollatorOptionsOptions forwarded to the Intl.Collator constructor, allowing fine-grained control over sensitivity, case handling, numeric ordering, and more. See {@link Intl.CollatorOptions}.

Released under the MIT License.