Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

241
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda