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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With