best algorithm to sort an array based on date code example Example: sort array by date const sortedActivities = activities.sort((a, b) => b.date - a.date)