我有一个类似于以下的数据库结构(FirebaseRealTimeDatabase):
我需要过滤数据,以便在回收站视图中从最高播放器到最低播放器显示数据:(如下所示)
Rico Hernandes - 40
Galvin Muro - 15
Another player - 5
这是代码,我用来获取数据:
ArrayList<String> profileNameList = new ArrayList();
ArrayList<String> profileStatusList = new ArrayList();
ArrayList<int> scoreList = new ArrayList();
databaseReference.child("players")
.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Iterable<DataSnapshot> children = dataSnapshot.getChildren();
for (DataSnapshot child : children) {
//Get the Names of the each player
Profile profile = child.child("profile").getValue(Profile.class);
//Get the Scores of the each player
Scores scores= child.child("scores").getValue(Scores.class);
profileNameList.add(profile.getName());
profileStatusList.add(profile.getStatus());
scoreList.add(scores.getScore());
}
}
我正在接收数据,但是我面临的挑战是对数据进行排序。如何获得理想的结果?
答案 0 :(得分:1)