Horje
javascript sort on objects date Code Example
javascript sort on objects date
array = [{
  			id: 1, name: "test1", date: "2020-01-05",
			id: 2, name: "test2", date: "2020-01-02"
		}]

array.sort(function (a, b) {
	var dateA = new Date(a.date), dateB = new Date(b.date)
	return dateA - dateB
});

console.log(array) //array is now sorted by date
javascript order array by date
const sortedActivities = activities.sort((a, b) => b.date - a.date)
sort array of objects javascript by 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);
});




Javascript

Related
acces store from vue console javascript Code Example acces store from vue console javascript Code Example
change display javascript Code Example change display javascript Code Example
express js clear cookie Code Example express js clear cookie Code Example
allow cross origin node Code Example allow cross origin node Code Example
remove a special character from string javascript Code Example remove a special character from string javascript Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10