function Sorter2D () {}
Sorter2D.prototype= {
aSortFunc : { "String" : function (a, b, Idx) {
if (a[Idx] == b[Idx]) return 0;
return a[Idx] < b[Idx] ? -1 : 1;
},
"Number" : function (a, b, Idx) {
return a[Idx] - b[Idx];
},
"Date" : function (a, b, Idx) {
switch (top.CompareDateTime(a[Idx], b[Idx])) {
case "Less":
return -1;
case "Greater":
return 1;
default:
return 0;
}
}
},
SortUnorderedColumn : function (aArray, SortColumn, SortType) {
var t= this;
if (!aArray || aArray.length < 2 || !t.aSortFunc[SortType]) return;
aArray= aArray.sort(function (a,b) { return t.aSortFunc[SortType](a, b, SortColumn)});
}
};
oSorter2D= new Sorter2D();
data=[ {data:0, text:"dsfgds" }, {data:45, text:"dsfgds" }.... ];
oSorter2D.SortUnorderedColumn(data, "text", "String");