Function alphaLocale

  • Returns a comparator function rather than being itself a comparator function. This is just a thin wrapper around the built-in String.prototype.localeCompare(), whose options are the same as Intl.Collator(), which is documented at MDN.

    For nullish values, null follows all strings, with undefined at the very end.

    Remarks

    As of this writing (January 3, 2023), some Android browsers do not support this function..

    Example

    import * as A from "flurp/array";
    import * as C from "flurp/comparator";

    const sortSv = A.sortWith(C.alphaLocaleNullable("sv", { sensitivity: "base" }));
    sortSv(["a", "ä"]); // ["a", "ä"]

    Parameters

    • Optional locales: string | string[]
    • Optional options: CollatorOptions

    Returns ((a: string, b: string) => number)

      • (a: string, b: string): number
      • Parameters

        • a: string
        • b: string

        Returns number