• Creates a Comparator that orders string values by their natural order, i.e. 'a' < 'aa' < 'ab'.

    Example

    Sort an Array of string values

    const array = ["ba", "aa", "ab"];
    array.sort(stringComparator());
    console.log(array); // ["aa", "ab", "ba"]

    Returns

    a Comparator for string values

    Parameters

    • Rest ...localeCompareArgs: [locales?: string | string[], options?: CollatorOptions]

      the arguments passed to String.prototype.localeCompare

    Returns Comparator<string>

Generated using TypeDoc