i having a date data which is coming in the form of DD/MM/YY and i am trying to sort it like this
const[sortOrder,setsortOrder]=Usestate('default');
processedDataBychoice=UseMemo(()=>{
return data.map(row,index)=>{
row.main=a.data;
return row;
}
},[data])
}
const finalData=useMemo(()=>{
processedDataByChoice.sort((rowA, rowB) => (new Date(rowB.main.last) - new Date(rowA.main.last)))
},[sortBy,sortOrder,processedDatabyChoice])
finalData.map((row, index) => {
main=row.main;
return(
<tr>{main.last}</tr>
);
);
but the data is not getting sorted any other way or i am doing something wrong in the code.
You can try this
processedDataByChoice.sort((rowA, rowB) => ((new Date(rowB.main.last)).getTime() - (new Date(rowA.main.last)).getTime()))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.