У меня проблемы с сортировкой списка объектов в React-native по значению времени.Я не могу найти ответ в Интернете.Есть ли у вас какие-либо предложения?
Мой консольный журнал в Chrome исходного объекта:
Структура базы данных Firebase
JSON.вывод stringify (myObject):
myObject={"-LAqmXKSdVVH6wirFa-g":
{"desc":"fdf","price":"rrrr","receiveHelp":true,"subject":"Single Variable
Calculus","time":1524558865757,"title":"Test1"},"-LAqmZlBFGoygfTsGQ0e":
{"desc":"dsfdsfd3","price":"333","receiveHelp":true,"subject":"Single
Variable Calculus","time":1524558875724,"title":"Test2"},"-
LAqmcipUjlwLWTrRCw4":
{"desc":"werwerwe55","price":"44","receiveHelp":true,"subject":"Single
Variable Calculus","time":1524558891956,"title":"Test3"},"-
LArMeYfHG6QMg_Frn9A":
{"desc":"3","price":"3","receiveHelp":true,"subject":"Single Variable
Calculus","time":1524568598762,"title":"Annons 1"},"-LArMjg5MkF5cMPZd_Fz":
{"desc":"2222","price":"2","receiveHelp":true,"subject":"Single Variable
Calculus","time":1524568619782,"title":"Annons2"},"-LArNM-3Ij60XmSOBwvr":
{"desc":"22","price":"","receiveHelp":true,"subject":"Single Variable
Calculus","time":1524568780803,"title":"Hej1"},"-LArNPugIfX1pPVZJ11e":
{"desc":"f","price":"2","receiveHelp":true,"subject":"Single Variable
Calculus","time":1524568796844,"title":"Hej2f"}}
Что я пробовал до сих пор:
firebase.database().ref('/users').once('value').then((snapshot) => {
const ads = snapshot.val();
let myObject = {};
Object.keys(ads).map((objectKey) => {
const value = ads[objectKey];
myObject = Object.assign(value.ads, myObject);
});
//Here i want to sort myObject by time and get the latest first
console.log(myObject)