When I wrote in JavaScript "?" > "Z" it returns true. In Unicode order it should be of course false. How to fix this? My site is using UTF-8.
"?" > "Z"
true
false
You can use Intl.Collator or String.prototype.localeCompare, introduced by ECMAScript Internationalization API:
Intl.Collator
String.prototype.localeCompare
"?".localeCompare("Z", "pl"); // -1 new Intl.Collator("pl").compare("?","Z"); // -1
-1 means that ? comes before Z, like you want.
-1
?
Z
Note it only works on latest browsers, though.
1.4m articles
1.4m replys
5 comments
57.0k users