1、数组中的对象排序
that.sjjsList.sort(function(a,b){
if (a.jsbl === b.jsbl) {
return a.distcode-b.distcode
} else {
return b.jsbl - a.jsbl;
}
});
2、时间排序
//反序
dataContent = ReverseRankingDate(dataContent, "received");
console.log(dataContent);
//封装的日期排序方法
function ReverseRankingDate(data, p) {
for (i = 0; i < data.length - 1; i++) {
for (j = 0; j < data.length - 1 - i; j++) {
console.log(Date.parse(data[j][p]));
if (Date.parse(data[j][p]) < Date.parse(data[j+1][p])) {
var temp = data[j];
data[j] = data[j + 1];
data[j + 1] = temp;
}
}
}
return data;
}