84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
有一系列的名称,包括中文和英文,使其按首字母排序,就像手机通讯录一样从A-Z进行排序。怎么做?谢谢
var arr = [9,8,7,6,5,1,'在', '我', '里', '阿','z','a','h','m']; arr.sort(function(a,b){return a.toString().localeCompare(b)}) //[1, 5, 6, 7, 8, 9, "阿", "里", "我", "在", "a", "h", "m", "z"]
你用sort()方法试试.sort
sort()
.sort(里面放个排序函数)
你用
sort()
方法试试.sort.sort(里面放个排序函数)