Skip to content

Novis\Intl\Collator

Sorts strings by the rules of a language and region. Each method takes a whole list and a locale tag, such as "de" or "sv-SE", and sorts the whole list in one call.

Members

2 members.

MemberSignature
sortsort(array<string> $strings, string $locale, ?CollateOptions $options = null): array<string>
sortKeyssortKeys(array<string> $strings, string $locale, ?CollateOptions $options = null): array<bytes>

Enums

  • Strength { Primary, Secondary, Tertiary, Quaternary, Identical }Which differences between two strings count when Collator sorts them. Collator sorts strings by the rules of a language. Primary compares the letters only, so "resume" and "Résumé" are equal. Secondary also compares accents. Tertiary also compares upper and lower case. This is the default. ignorePunctuation is another option of Collator. When it is true, Primary, Secondary and Tertiary do not compare punctuation. Quaternary also compares that punctuation. Identical also compares the characters themselves when everything else is equal.
  • CaseFirst { Off, Upper, Lower }Whether uppercase or lowercase letters come first when Collator sorts words that differ only in case. Collator sorts strings by the rules of a language. Off is the default. It follows the rules of the language. In English, it puts "apple" before "Apple". Upper puts "Apple" first. Lower puts "apple" first.

Types

CollateOptions

type CollateOptions = {    strength?: Strength,    caseFirst?: CaseFirst,    numeric?: bool,    ignorePunctuation?: bool,};