res.result.items.sort(that.compare("id")); compare: function (property) { return function (a, b) { var value1 = a[property]; var value2 = b[property]; return value2 - value1; } },
以上代码是以依据id字段进行倒序排序,如需正序排序,则为value1-value2
res.result.items.sort(that.compare("id")); compare: function (property) { return function (a, b) { var value1 = a[property]; var value2 = b[property]; return value2 - value1; } },
以上代码是以依据id字段进行倒序排序,如需正序排序,则为value1-value2