question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Order Firebase RecyclerView by Child Value

See original GitHub issue

I have a data structure (see below) and I essentially want to create a “trending” section that emphasizes the items that have the most votes. Votes are accounted for in the vote_count field of my Firebase database.

I know there is the .orderByChild() method available in Firebase. Would it be possible to have my RecyclerView sort the data based on the value of the vote_count child (descending order)?

image

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
karamJABcommented, Mar 17, 2019

@jesusignazio setReverseLayout with your layout manager and then setstackfromend will do the descending order

1reaction
SUPERCILEXcommented, Jan 31, 2017

@troy21688 No, that’s good. Since you can pass in a query, just use orderByChild("vote_count") for the query/ref you pass into your adapter.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ordering Firebase Data in Arraylists/RecyclerView
Since you are using firebase datastore. You can sort the values by these 3 methods in it. orderByChild() orderByKey() orderByValue().
Read more >
Work with Lists of Data on Android - Firebase - Google
You can use the Realtime Database Query class to retrieve data sorted by key, by value, or by value of a child. You...
Read more >
Android Firebase 05 : RecyclerView – Sorting Data - YouTube
In this part we will apply sorting with sorting options "Newest" & "Oldest" to Firebase data displayed in RecyclerView.
Read more >
retrieve data from firebase to recyclerview - YouTube
This document covers the basics of retrieving data and how to order and filter Firebase data.In this video I will show you how...
Read more >
How to populate RecyclerView with Firebase data using ...
All data values are stored in a string format for ease. ... your app/build.gradle file in order to get the FirebaseUI and Firebase...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found