Skip to content
Open navbar menu
Sign UpLog In
Profile icon

Dylan Dale

@DylanDale
Repls
Community
DylanDale
DylanDale
shared a Post
2 years ago
Is there a way to get the highest value stored in the repl database?
I want to make a leaderboard for my game that displays people with the highest number of coins.
CodingElf66
CodingElf66
Yes, it is possible. scores = [] leaderboard = {} for key in db.keys(): scores.append(db[key]) highscore = max(scores) for key in db.keys(): if db[key] == highscore: leaderboard[key] = db[key] scores.pop(leaderboard[key]) highscore = max(scores) Assuming that the key is the username, and db[key] is their highscore, then this would sort it in order. Now you can mark it as answered, thank you!2 years ago
MrVoo
MrVoo
Make a copy of the leader board, get the highest value and move it to a separate list. Repeat until the copy is empty, and the separate list has the scores in order.2 years ago
IntellectualGuy
IntellectualGuy
When someone tries to take a look at the score, then you could get all of the values of the database and rearrange them based on score.2 years ago