I have a Database
with the Ranking
of my Game. I trying to get the most high score players.
I trying to order by
score
. I tried some different queries but it doesn't ordering! It returns all the elements but not ordered.
What should I do?
Code:
Database.database().reference().child("ranking")
.queryOrdered(byChild: "score")
.observe(.value, with: {
(snapshot: DataSnapshot) in
let ranking = snapshot.value as! NSDictionary
for rankingPlayer in ranking {
let player = rankingPlayer.value
print(player)
}
})
Database:
PS: Why not order after got the snapshot result? Because I will have thousands of scores and I will just limit my query to the ten biggest high scores.