Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript sort support for multilanguage

Tags:

javascript

We have a country dropdown list in our page.

we have a new requirement to sort the country name based on alphabetical order. But the country name will be populated in different language based on user. If the user is a Japanese user, the country list will be in Japanese language. Will the javascript sort work if the country names are in multi language?

like image 826
user2907217 Avatar asked Dec 31 '25 08:12

user2907217


1 Answers

Assuming Unicode you can try using localeCompare to get it in alphabetical order, (see: https://stackoverflow.com/a/6909444/1059070)

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare

Otherwise I believe it will sort according to the unicode character value

like image 117
arcyqwerty Avatar answered Jan 02 '26 21:01

arcyqwerty



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!