Javascript sort support for multilanguage

javascript

Solution

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

Problem

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?

Original source

Related problems