I have an application to post articles The data is saved in Firebase I want articles to be sorted by Newest how I can do that I have an application to post articles The data is saved in Firebase I want articles to be sorted by Newest how I can do that
private void postDataLoad() {
postDatabaseReference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
postList.clear();
for (DataSnapshot dataSnapshot : snapshot.getChildren()) {
PostModel model = dataSnapshot.getValue(PostModel.class);
postList.add(model);
}
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
}
});
}
private void profileDataListLoad() {
databaseReference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
profileList.clear();
for (DataSnapshot dataSnapshot : snapshot.getChildren()) {
ProfileModel profileModel = dataSnapshot.getValue(ProfileModel.class);
if (!currentId.equals(profileModel.getId())) {
profileList.add(profileModel);
}
}
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
}
});
}