javascript - Compare and sort strings in multiple languages -


i need sort in js strings alphabetically. in english sorting quite easy:

sortarr.sort( function ( , b ) {   return > b ? 1 : -1; } ); 

however app working on translated i.a. arabic, chinese, german, russian , few others. can see non ascii characters results seems not right.

i found intl.collator().compare according docs:

the intl.collator object constructor collators, objects enable language sensitive string comparison.

however, it's not supported safari , of mobile browsers.

is there other solution can use?

edit

there string.prototype.localecompare() browser support not enough too.

short answer no.
every language has own alphabetic order. example russian has letter 'с' in different order turkish. option imo use collator when possible (browsers support it). afaik there aren't other ready-to-go libraries or object can use achieve this.


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -