Why does String#localeCompare put "ʻ" (ʻOkina) between H and I?

Viewed 35

Background

ʻ, the ʻOkina, Unicode code point U+02BB MODIFIER LETTER TURNED COMMA, is:

a unicameral consonant letter used within the Latin script to mark the phonemic glottal stop, in many Polynesian languages

Not to be confused with ' or even , which are straight and curly single-quotation marks, respectively.

Question

Why does this:

[...'hiʻ'].sort((a, b) => a.localeCompare(b)).join('')

Yield hʻi as its answer? In other words, on what basis does localeCompare judge that the ʻOkina comes after H and before I in the alphabet?

The ECMAScript standard simply mentions that "The two Strings are compared in an implementation-defined fashion", yet both Chromium and Firefox are in agreement about this ordering, at least in the en-US locale.

It seems most (all?) languages that include in their alphabets simply place it at the end. Is there some Unicode standard somewhere that defines alphabetical ordering that both Chromium and Firefox use? Or if not, where did they both get the idea that falls between H and I?

1 Answers

Wow, that is really interesting placement.

Is there some Unicode standard somewhere that defines alphabetical ordering that both Chromium and Firefox use?

Yes. Collation (as it's called) is a big topic. It's covered in various places by Unicode, for instance in Unicode Technical Report 10 and at least in part in TR15. I haven't found a specific rationale for how the ʻOkina is handled, but in general as I understand it the rules are designed to ensure that a locale (not just language) can specify how characters are collated in that locale.

That doesn't necessarily mean the placement will make sense in an English-speaking locale like en-US or en-GB, but hopefully in a locale properly supporting Polynesian languages, it would be collated in a way that makes sense.

I'm not sure this is an answer so much as a pointer to where to find one. I wish I could point to the specific reason. I'm sure there is one, it hasn't just been put there randomly. It (the reason) will likely be in the collation data files in a comment. Or a native speaker might be able to say off the top of their head "Well of course that's where it goes, because ________."

Related