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:
Query leader_board_query = leader_board_reference.child(week_id).orderByValue().limitToLast(10);
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()); layout_manager.setReverseLayout(true); layout_manager.setStackFromEnd(true);
The list got ordered in reverse which is resulted in ordering from highest to lowest.