javascript - 如何根据日期对 JavaScript 中的对象进行排序

标签 javascript

输入数据

 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"
  }

预期输出

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"
  }

我们必须根据日期排列数据。不是键

最佳答案

您可以使用数组实用函数,例如reducesortenter image description here

关于javascript - 如何根据日期对 JavaScript 中的对象进行排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61360435/

相关文章:

javascript - then 不是函数错误 - Node Promise 库

带有地理坐标图的美国 Javascript map

javascript - React-router 不变违规 : The root route must render a single element

javascript - 如果 firebaseRef 设置为新值,是否需要调用 .off() ?

javascript - 使用 websocket 处理连接丢失

javascript - 在自定义 View 中调用 super() 时,确保传递与传递组件的构造函数相同的 Prop

javascript - 保持元素可滚动直到到达最后一个内容

javascript - 如何禁用浏览器默认密码弹出窗口?

javascript - 我无法将initialValues 用于 redux-form,我该怎么办?

javascript - 如何将提示中的多个输入添加到数组中?