I am currently working on an android app that shows times/dates for rides to and from certain locations. I want to sort my firebase objects so that objects are sorted based on date. I tried searching online and playing with the methods ref.setPriority(...), and ref.orderByChild(...), but I cannot find a clear way on doing this.
This is what my database looks like currently

I have the date in a long data type, and I want my firebase recycler view to show the rides in ascending order, in terms of how soon the ride is from the current date. Thanks!
You can query like this:
Query query = mRideRef.orderByChild("date");
And then set a listener to get the values
Adding onto Rosario's answer, I just want to say after creating the query, just inject it into the firebase recycler adapter as the final parameter to get a sorted recycler view. Didn't realize that it had the option but it works perfectly now!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With