This is probably a classic issue: I have a "dictionary" of scores for each player:
var scores = {
'player1' : 9,
'player2' : 3,
'player3' : 7,
'player4' : 5
}
I want to transform this into a Leaderboard with as key, the position calculated on the number of players and the value, the name of the player:
var leaderboard = {
1 : 'player1',
2 : 'player3',
3 : 'player4',
4 : 'player2'
}
How do I do this in a clean way, without messing too much with temporary lists and dictionaries? Thank you.