I have news data in Firebase in following format:
I want to sort it according to date (newsDate
) in descending order (latest on the top). I have added this to my code while I am retrieving data from Firebase:
databaseReference.orderByChild("newsDate").addChildEventListener(new ChildEventListener() {
// on child added methods
}
But this only does string sorting, so that order becomes like this: 04/08/2018 12:00, 13/08/2018 10:30, 30/07/2018 00:00
I know this is because of alphabetical sorting. Wondering how I can customize sorting order with my date format (dd/mm/yyyy hh:mm) and also in descending order?