Function ordinalCompare

  • Compares two strings using an ordinal comparison approach based on the specified collation options. This function uses the built-in localeCompare method with the 'en' locale and the provided collation options to compare the strings.

    Parameters

    • string1: string

      The first string to compare.

    • string2: string

      The second string to compare.

    • Optionaloptions: CollatorOptions

      Optional. The collation options used for comparison.

    Returns number

    A number indicating the result of the comparison: - Negative value if string1 precedes string2 in sorting order. - Zero if string1 and string2 are equivalent in sorting order. - Positive value if string1 follows string2 in sorting order.