Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

localization #1

Open
rotsee opened this issue May 29, 2015 · 2 comments
Open

localization #1

rotsee opened this issue May 29, 2015 · 2 comments

Comments

@rotsee
Copy link

rotsee commented May 29, 2015

Very nice one! Would it somehow be possible to use localeCompare in the quicksort algorithm, so that we can use it on other languages than English?

@pozitron57
Copy link

Hi @rotsee, I use tsorter.js with Russian with no problems.

@rotsee
Copy link
Author

rotsee commented Dec 3, 2017

@pozitron57 I should probably give an example: In Swedish å, ä, and ö comes after z in the alphabet. In German äand ö comes before (there is no å). There are thousands of examples where sorting depends on language and/or locale. localeCompare is a native string method making localized sorting possible, that has very good browser support: https://caniuse.com/#search=localeCompare (Hey, even IE6 has at least some basic support!)

Usage:

console.log('ä'.localeCompare('z', 'sv'));  // 1
console.log('ä'.localeCompare('z', 'de'));  // -1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants