數據結構如下:
需求:按照fid降序排列。(某種情況下後臺不方便直接排序,前臺亦可只不過速度慢)
function by(name){
return function(o, p){
var a, b;
if (typeof o === "object" && typeof p === "object" && o && p) {
a = o[name];
b = p[name];
if (a === b) {
return 0;
}
if (typeof a === typeof b) {
return a > b ? -1 : 1;
}
return typeof a > typeof b ? -1 : 1;
}
else {
throw ("error");
}
}
}
var list=data.rows.sort(by("fid"));