1var array = [{id: 1, date:'Mar 12 2012 10:00:00 AM'}, {id: 2, date:'Mar 8 2012 08:00:00 AM'}];
2
3
4array.sort(function(a, b) {
5 var c = new Date(a.date);
6 var d = new Date(b.date);
7 return c-d;
8});
9
1const activities = [
2 { title: 'Hiking', date: new Date('2019-06-28') },
3 { title: 'Shopping', date: new Date('2019-06-10') },
4 { title: 'Trekking', date: new Date('2019-06-22') }
5]
6
1array.sort(function(o1,o2){
2 if (sort_o1_before_o2) return -1;
3 else if(sort_o1_after_o2) return 1;
4 else return 0;
5});
1 arr = arr.sort(function (a, b) {
2 var dateA = new Date(a.date_prop).getTime();
3 var dateB = new Date(b.date_prop).getTime();
4 return dateA < dateB ? 1 : -1;
5 });
6