I am trying to figure out how to sort my array by objects in that array. In this example I want to be be able to sort my array by player name, or by player score.
var topPlayers = new Array();
$(".player").each( function(i) {
topPlayers[i] = {};
topPlayers[i]["name"] = $(this).children(".name").text();
topPlayers[i]["score"] = $(this).children(".score").text();
});
topPlayers.sort(function(a.name,b.name){return a.name-b.name}); //This is the line of code I can't figure...