问题描述
想把这个按照7月19日-7月16日反过来排序。请教如何处理呢?
问题出现的环境背景及自己尝试过哪些方法
相关代码
for (let i = 0; i < rs.length; i++) {
let timeKey = moment(rs[i].timestamp).format("YYYY/MM/DD");
if (this.direction === 1) {
if ((timeKey in curDatas) === true) {
curDatas[timeKey].unshift(rs[i])
console.log(curDatas[timeKey]);
} else {
curDatas[timeKey] = [];
curDatas[timeKey].unshift(rs[i])
}
} else {
if ((timeKey in curDatas) === true) {
curDatas[timeKey].push(rs[i])
} else {
curDatas[timeKey] = [];
curDatas[timeKey].push(rs[i])
}
}
}
你期待的结果是什么?实际看到的错误信息又是什么?
direction代表向上向下的方向,所以有一个判断。
想让最后的curDatas 按照20190719-20190718-201190716 的顺序排列该如何操作?
只是倒序过来吧?