Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript sort array of objects by value of key in object

//Sort Objects in array Descending order
const sortDesc(a,b) => {
  return b.timestamp - a.timestamp;
}

//Sort Objects in array Ascending order
const sortAsc(a,b) => {
  return a.timestamp - b.timestamp;
}

<Array>.sort(sortAsc);
<Array>.sort(sortDesc);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #sort #array #objects #key #object
ADD COMMENT
Topic
Name
4+9 =