需求:根据时间倒序排列新闻列表
image.png let newList = [
{title:'新闻',time:'2017-12-30'},
{title:'新闻',time:'2018-09-30'},
{title:'新闻',time:'2018-12-30'},
];
newList.sort((a,b) => {
return a.time > b.time ? 1 : -1;
})
console.log(newList)
image.png