tsorter
tsorter copied to clipboard
localization
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?
Hi @rotsee, I use tsorter.js with Russian with no problems.
@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