1 var rows=[
2 [4,"000004",1],
3 [5,"600000",2],
4 [1,"000001",1],
5 [2,"000002",1],
6 [3,"000003",1],
7 [6,"600002",2],
8 [7,"600003",2],
9 [8,"300001",2],
]
//a:索引,b:排序方向,c:类型,0:数字,1:中文
var compare = function(a, b, c) {
//比较的两个值
return function(d, e) {
var g;
d = d[a];
e = e[a];
var f = b == 1 ? false: true;
if (c == 0) {
d = typeof d == "undefined" || d.toString() == "" ? (-999999*b): eval(d);
e = typeof e == "undefined" || e.toString() == "" ? (-999999*b): eval(e);
g = f ? d > e ? 1: d < e ? -1: 0: d < e ? 1: d > e ? -1: 0
} else if (c == 1) {
d = typeof d == "undefined" ? "": d;
e = typeof e == "undefined" ? "": e;
return f ? d.localeCompare(e) : e.localeCompare(d)
}
return g
}
};
rows.sort(compare(2,1,0));
for(var i=0;i<rows.length;i++){
//alert(rows[i]);
}