I am using Firebase as a backend for my notes making Android application and using "FirestoreRecyclerAdapter" for fetching the data from it. I want that data in reverse sorted order.
How can I achieve this using the FirestoreRecyclerAdapter?
database = FirebaseFirestore.getInstance(); reference = database.collection("users").document(currentUserId).collection("notes"); query = reference.orderBy("lastUpdated");
this query fetch data in sorted order in
StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(2, 1);
CodePudding user response:
Use Query.Direction.DESCENDING to sort in descending order in java;
query = reference.orderBy("lastUpdated",Query.Direction.DESCENDING);