We have a Mario Kart tournament at work and I wanted to try and log the results using basic JavaScript.
Here's the code: https://jsbin.com/hafati/44/edit?js,console
I've nearly got there, but I need help sorting the results.
Here's the console.log
of the data:
[object Object] {
1: [object Object] {
id: 1,
name: "Player 1",
total: 20
},
2: [object Object] {
id: 2,
name: "Player 2",
total: 60
},
3: [object Object] {
id: 3,
name: "Player 3",
total: 80
},
4: [object Object] {
id: 4,
name: "Player 4",
total: 400
},
5: [object Object] {
id: 5,
name: "Player 5",
total: 150
},
6: [object Object] {
id: 6,
name: "Player 6",
total: 50
}
}
How would you sort these players, with the highest total
first?