arrange dates in ascending order in react code example
Example 1: sort data according to date in js
array.sort(function(a,b){
// Turn your strings into dates, and then subtract them
// to get a value that is either negative, positive, or zero.
return new Date(b.date) - new Date(a.date);
});
Example 2: array map order by timestamp reactjs
const sortedActivities = activities.slice().sort((a, b) => b.date - a.date)