I have a multiplayer game and the gameplay data is stored like this:
var gameplays = [
{id: "1", player1: "bob", player2: "tim", score1: 2, score2: 14},
{id: "2", player1: "bob", player2: "tim", score1: 7, score2: 3},
{id: "3", player1: "bob", player2: "tim", score1: 6, score2: 10},
{id: "4", player1: "bob", player2: "tim", score1: 5, score2: 1}
];
What is the most efficient way to find the top 5 highscores from all the games by searching "score1" and "score2" and output them like this:
HIGHSCORES
1. Tim - 14
2. Tim - 10
3. Bob - 7
4. Bob - 6
5. Bob - 5