凌的博客

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

Js

js中文按字母排序

2016-10-15 Js 1089
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条评论