Rahul Saini
Rahul Saini

Reputation: 937

How to sort object in JavaScript based on date

Input Data

 var data =  {
    "36905b7cb": "(2019-12-26 T 13H-39M-0S) Co-Testing",
    "cad5dd7ea": "(2019-12-05 T 16H-38M-9S) Diagnosis",
    "sad4217ea": "(2020-03-05 T 16H-38M-9S) Bio-Testing"
  }

Expected Output

var data =  {
    "sad4217ea": "(2020-03-05 T 16H-38M-9S) Bio-Testing"
    "36905b7cb": "(2019-12-26 T 13H-39M-0S) Co-Testing",
    "cad5dd7ea": "(2019-12-05 T 16H-38M-9S) Diagnosis"
  }

we have to arrange the data in the sorted based on date.Not the KEYS

Upvotes: 0

Views: 55

Answers (1)

Anarno
Anarno

Reputation: 1640

You can use the array util functions like reduce, sort. enter image description here

Upvotes: 1

Related Questions