📜  如何在 javascript 代码示例中按日期 desc 重新排列对象数组

📅  最后修改于: 2022-03-11 15:02:01.810000             🧑  作者: Mango

代码示例1
array.sort(function(a,b){
  // Turn your strings into dates, and then subtract them
  // to get a value that is either negative, positive, or zero.
  return new Date(b.date) - new Date(a.date);
});