使用方法:localeCompare
运行如下范例可见效:
var str = "张韶涵,b土,abort,张学友,something,苹果,五月天,刘德华,香蕉,apple,范玮琪,阿桑";
var strArr = str.split(',');
alert(strArr.sort());
alert(strArr.sort(function(a, b){return a.localeCompare(b);}));
使用方法:localeCompare
运行如下范例可见效:
var str = "张韶涵,b土,abort,张学友,something,苹果,五月天,刘德华,香蕉,apple,范玮琪,阿桑";
var strArr = str.split(',');
alert(strArr.sort());
alert(strArr.sort(function(a, b){return a.localeCompare(b);}));