I've been trying to sort a top-5 leaderboard which includes the score and the username of the account that got the score. Here is my current code:
g = open("scores.txt", "r")
score1 = g.readline().strip()
score2 = g.readline().strip()
score3 = g.readline().strip()
score4 = g.readline().strip()
score5 = g.readline().strip()
print(score1,score2,score3,score4,score5)
print(sorted([score1,score2,score3,score4,score5], reverse = True))
g.close()
It seems to work, but it only sorts the leftmost digits of the scores, for example it sorts 100coolguy 50otherguy 10coolguy 2000coolguy 2otherguy
as 50otherguy 2otherguy 2000coolguy 10coolguy 100coolguy
.
A list of the scores, and how they should be formatted afterwards:
100otherexample 50example 10otherexample 2000example 2example
2000example 100otherexample 50example 10otherexample 2example