IE and Chrome Firefox sorting compatibility problem, sort by zh-Hans-CN

var chineseArr = ["", "", "", "", "Goolge", "AHHH"];
var newChineseArr = chineseArr.sort(function (a, b) {
    return a.localeCompare(b, "zh-Hans-CN", {sensitivity: "accent"});
});
console.log(newChineseArr);

Export Ali, Baidu, Huawei and Tencent, AHHH, Goolge, under Chrome and Firefox
export AHHH, Goolge, Ali, Baidu, Huawei and Tencent
under IE. It is mainly the problem of zh-Hans-CN

Jul.06,2021

Let the backend handle it. Add a sort field to each information, and then look it up according to the sort field when you check it


it is estimated to be difficult.

another solution is provided here. Refer to a Chinese-to-pinyin library ( pinyinjs ) to convert Chinese to Pinyin first, and then make a comparison.

Menu