i have this react app
i am trying to sort datas from it date wise (latest date comes top in the list )
the date is stored in two differnt pattern some are in yyyy-mm-dd and some are in dd-mm-yyyy
i am trying to sort both
where latest date comes in top of the list format
const sortedOnDate = Object.values(groupedByDate).sort((arr1, arr2) => {
if (arr1[0].date < arr2[0].date) {
return -1;
} else if (arr1[0].date > arr2[0].date) {
return -1;
}
return 0;
});
entire code i am adding in code sandbox
https://codesandbox.io/s/exciting-sea-ins4vt?file=/src/App.js