Reputation: 4482
I am trying to sort projects based on the dateAdded:
The tree looks like this:
projects: {
"someprojectId": {
dateAdded: Firebase.TimeStamp
},
"someProjectid2":{
dateAdded: Firebase.Timestamp
}
}
I am calling it like so in android:
mDatabase.child("projects").orderByChild("dateAdded").addValueEventListener(new ValueEventListener() {
However, it is not sorting it correctly, or at all for that matter of fact?
Upvotes: 1
Views: 9371
Reputation: 598785
It would help to see how you actually handle the data in onDataChange
. But my guess is that you're failing to loop over the children:
mDatabase
.child("projects")
.orderByChild("dateAdded")
.addValueEventListener(new ValueEventListener() {
public void onDataChange(DataSnapshot snapshot) {
for (DataSnapshot child: snapshot.getChildren()) {
System.out.println(child.getKey());
}
}
...
Upvotes: 5