javascript sort array by latest date code example
Example 1: javascript order array by date
const sortedActivities = activities.sort((a, b) => b.date - a.date)
Example 2: javascript sort array of date
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);
});