I'm using CSV to sort the players highest sore. I have the name and scores in a list like this:
['4', 'Score One']
['8', 'Score Two']
['6', 'Score Three']
Which has been created from looping through the file, finding the maximum score and making a new list with this score and the player name.
for row in reader:
highscores = ([row[-1], row[0]])
When I print (sorted(highscores))
the same list is returned to me. What I want it to sort as is:
['8', 'Score Two']
['6', 'Score Three']
['4', 'Score One']
If someone could explain to me why sorted
doesn't work and what I could do to fix it, that'd be great.