Function sorter

  • Sorter factory function

    Parameters

    • Optionallocales: string | string[]

      A string with a BCP 47 language tag, or an array of such strings.

    • Optionaloptions: CollatorOptions

      An object adjusting the output format.

    Returns <T = string, P = string>(a: T, b: P) => number

    • compare function
    const items = ['啊我', '波拉', 'abc', 0, 3, '10', ',11', 13, null, '阿吧', 'ABB', 'BDD', 'ACD', 'ä']

    items.sort(
    sorter('zh-Hans-CN', {
    ignorePunctuation: true,
    sensitivity: 'variant',
    numeric: true
    })
    )
    // [ 0, 3, "10", ",11", 13, "ä", "ABB", "abc", "ACD", "BDD", null, "阿吧", "啊我", "波拉" ]

    5.14.0