我有與字符串相同的數組,但他們it
數組排序不正確,它從我的電腦複製。在瀏覽器中輸入items
。字符串在Javascript中排序不正確
https://jsfiddle.net/acc8xf0g/
var items = ["hard", "intermediate", "easy"];
var it = [
"intermediate",
"hard",
"еasy"
];
items.sort(function(a, b) {
return a.localeCompare(b);
});
it.sort(function(a, b) {
return a.localeCompare(b);
})
$("#test").html(items.join(" "));
$("#test2").html(it.join(" "));
它實際上不是相同的數組。你從哪裏得到第二個數組? –