spongyboss spongyboss - 1 month ago 11x
Android Question

Android - Firebase order by value

I have a node with a list of user scores in a Firebase DB, I would like to order the list from highest to lowest and show only the top 10 scores:

My leaderboard node:

-$user_id: score

And my java code is as follows:

Query leader_board_query = leader_board_reference.child(week_id).orderByValue().limitToLast(10);

For some odd reason, it always orders from lowest to highest. I have tried using
and nothing changes, please help


I managed to solve this painful problem. All I had to do was alter my recyclerview layout a bit by adding the following lines of codes to its layout manager.

LinearLayoutManager layout_manager = new LinearLayoutManager(getContext());

The list got ordered in reverse which is resulted in ordering from highest to lowest.