Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

240
Visualizações
Why does String#localeCompare put "ʻ" (ʻOkina) between H and I?

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?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

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 ________."

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda