I am creating simple News application, And i am using Firebase as back-end, I have stored News articles in Cloud firestore, In my fields i have News publication time hr:min:sec I want to sort received data by publication time, from the latest to the oldest, any solutions? Thanks in advance
var data = [
{ news: [
{ published_at: "2/22/2021",
imgUrl: "",
id: 159783,
title: "short descr",
date: "18:11:53",
previewText: "some kind of title" }
],
newsId: "5GTAbGLfS0hSCOkmTfHD"
},
{ news: [
{ id: 159783,
published_at: "2/22/2021",
previewText: "some kind of title2",
title: "short descr",
date: "17:19:53",
imgUrl: ""
}
],
newsId: "lw2hzVe0m3dbcmvBj4Vz" }
]
data.forEach((item)=>{
var singleItem = item.news
const finalResult = singleItem.sort((a, b) => b.date - a.date)
console.log(finalResult)
})