以下日期如何按照从小到大排序?
尝试方案:想着用sort
day.sort((a,b)=>{
return Number(a.date.slice(0,2))-Number(b.date.slice(0,2))
})
})
想得倒是挺美好,可惜它实现不了,why??
let day = [
{date:'15日',value:'xxx'},
{date:'06日',value:'xxx'},
{date:'16日',value:'xxx'},
{date:'18日',value:'xxx'},
{date:'02日',value:'xxx'},
{date:'25日',value:'xxx'},
{date:'21日',value:'xxx'},
{date:'10日',value:'xxx'}
];
看岔了,我写的是对的。 = =