javascript sort array of objects by date

113

javascript order array by date -

const sortedActivities = activities.sort((a, b) => b.date - a.date)

js order array of objects by date -

 arr = arr.sort(function (a, b) {
      var dateA = new Date(a.date_prop).getTime();
      var dateB = new Date(b.date_prop).getTime();
      return dateA < dateB ? 1 : -1;
    });

sort by date javascript -

array.sort(function(a,b){return a.getTime() - b.getTime()});

Comments

Submit
0 Comments