Open better2021 opened 3 years ago
var array = ['白鸽', '麻雀', '大象', '狗', '猫', "鸡"]; array = array.sort(function compareFunction(a, b) { return a.localeCompare(b); }); console.log(array ) // ['白鸽', '大象', '狗', '鸡', '麻雀', '猫'] array = array.sort(function compareFunction(a, b) { return b.localeCompare(a); }); console.log(array ) // ['猫', '麻雀', '鸡', '狗', '大象', '白鸽']