简体   繁体   English

如何根据日期对 JavaScript 中的 object 进行排序

[英]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预计 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不是钥匙

You can use the array util functions like reduce , sort .您可以使用数组 util 函数,如reducesort 在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM