凌的博客

您现在的位置是:首页  > 前端学习 > Js

Js

js中文按字母排序

2016-10-15Js0
window.onload = function(){ var city = ["北京","上海","深圳","武汉","济南","天津"]; console.log(city); city.sort(function(param1,param2){ return param1.localeCompare(param2); }); console.log(city); }
window.onload = function(){
	var city = ["北京","上海","深圳","武汉","济南","天津"];
	console.log(city);
	city.sort(function(param1,param2){
		return param1.localeCompare(param2);	
	});
	console.log(city);
}


如果本文对您有所帮助,请支持下本站哦!!!^_^

文章评论

0条评论