I have a game in python which takes info about the user and even stores the points. I wanted to make a leaderboard for it and so I decided to use Firebase and write the data into the database. I would just like the arrangement of the data to be in descending order based on the points limited upto the Top 20 ranks because the data is just randomly arranged now. Help will be appreciated. Thanks!
My code:
#Example Set
ref = db.reference('/')
ref.set({
'Data':
{
'user'+str(userCounter): {
'Username':userid,
"Points": highscore
}
}
})
#Updating Data
if current_score > highscore:
ref = db.reference('Data')
emp_ref = ref.child('user'+str(id))
emp_ref.update({
"Points": current_score
})