var city = ["北京","天津","上海","重庆","杭州"];
city.sort(function compareFunction(a,b){ return a.localeCompare(b); }); console.log(city); ==>["北京", "重庆", "杭州", "上海", "天津"]
var city = ["北京","天津","上海","重庆","杭州"];
city.sort(function compareFunction(a,b){ return a.localeCompare(b); }); console.log(city); ==>["北京", "重庆", "杭州", "上海", "天津"]