如:第一个是姓名 ,第二个是 手机 第三个是邮箱
testArray[0]= new Array('张三','1314662544','[email protected]');
testArray[1]= new Array('aa','1331154647','[email protected]');
testArray[2]= new Array('李四','132112154','[email protected]''); ....testArray[i]= new Array('王六','139111122','[email protected]');
点击姓名时候
排序为
testArray[0]= new Array('aa','1331154647','[email protected]');
testArray[1]= new Array('李四','132112154','[email protected]'');
...
testArray[3]= new Array('王六','139111122','[email protected]');testArray[i]= new Array('张三','1314662544','[email protected]');姓名:按照姓名音序a-z进行排序。同一音序下,先显示英文姓名,再显示中文姓名手机:按照手机数字0-9进行排序私人邮箱:按照大写字母(A-Z)、小写字母(a-z)进行排序
testArray[0]= new Array('张三','1314662544','[email protected]');
testArray[1]= new Array('aa','1331154647','[email protected]');
testArray[2]= new Array('李四','132112154','[email protected]''); ....testArray[i]= new Array('王六','139111122','[email protected]');
点击姓名时候
排序为
testArray[0]= new Array('aa','1331154647','[email protected]');
testArray[1]= new Array('李四','132112154','[email protected]'');
...
testArray[3]= new Array('王六','139111122','[email protected]');testArray[i]= new Array('张三','1314662544','[email protected]');姓名:按照姓名音序a-z进行排序。同一音序下,先显示英文姓名,再显示中文姓名手机:按照手机数字0-9进行排序私人邮箱:按照大写字母(A-Z)、小写字母(a-z)进行排序
var arr = [['张三','1314662544','[email protected]'], ['aa','1331154647','[email protected]'], ['李四','132112154','[email protected]'], ['王六','139111122','[email protected]']];
function arrSorting(o){
o == 0 ? arr.sort(function(x, y){
return x[0].localeCompare(y[0])
})
: o == 1 ? arr.sort(function(x, y){
return x[2] > y[2] ? 1 : -1
})
: arr.sort();
return arr
}
</script>
<input type=button value="按姓名排序" onclick="alert(arrSorting(0))">
<input type=button value="按邮箱排序" onclick="alert(arrSorting(1))">