Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

typescript sort array of objects by date descending

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; // ? -1 : 1 for ascending/increasing order
    });
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #typescript #sort #array #objects #date #descending
ADD COMMENT
Topic
Name
9+7 =