利用sort 进行汉字的排序

 

 

 

根据汉字首字母a---z进行排序

let arry = ['周浩','李媛','王五','安妮']

arry.sort(function(a,b){
  return a.localeCompare(b)
})
console.log(arry)

["安妮", "李媛", "王五", "周浩"]

 

相关文章: