tsorter icon indicating copy to clipboard operation
tsorter copied to clipboard

localization

Open rotsee opened this issue 9 years ago • 2 comments

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?

rotsee avatar May 29 '15 11:05 rotsee

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

pozitron57 avatar Dec 07 '15 16:12 pozitron57

@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

rotsee avatar Dec 03 '17 20:12 rotsee