locale-compare
v2.0.0
Published
Locale-aware string comparison with Intl.Collator and localeCompare fallback
Downloads
958
Maintainers
Readme
locale-compare
Locale-aware string comparison with Intl.Collator
and localeCompare
fallback.
Usage
// ES6 Modules (Babel)
import localeCompare from "locale-compare";
const compare = localeCompare();
const compareInSwedish = localeCompare("sv");
// CommonJS (Node.js):
var compare = require("locale-compare")();
var compareInSwedish = require("locale-compare")("sv");
// Use with Array.sort
["ä", "z"].sort(compare);
["ä", "z"].sort(compareInSwedish);