How to order fetched images from Firebase, from most recent to oldest?

Viewed 71

I currently have a app where images are uploaded to firebase and then retrieved when pressing a button. However in firebase they are arranged in alphabetical order. How can I make the "posts" be arranged from newest to oldest post? My DB structure:

    {
  "Posts" : {
    "ThisWouldBeRandomUID" : {
      "post:RandomUIDHere" : {
        "ImageUrl" : {
          "image1" : "https://URLHere",
          "image2" : "https://URLHere"
        }
      }
    },
  "users" : {
    "7AM0CeJ71tYON9NejziFZto16fk2" : {
      "email" : "dhhfhfhffhdh@hdhdhdjdh.hehdhdhdh",
      "password" : "dhdhdhhdhdhdhdhdhfhf"
    }
  }
}
1 Answers

So far I didnt see something like that function in exists in firebase, in my case after getting all the "post" data (it is arranged from oldest to new) I store the "data" returned from the real time database query in a object and using reverse() function in javascript I successfully sort the post from new old. Hope this helps

Related