how would I sort this array so the member with the highest points prints first?
[FONT=Courier New]
var members = [{
name: "stephen gupta",
points: 52
},{
name: "laura kowalski",
points: 67
},{
name: "John Rodriguez",
points: 33
}];
[/FONT]
how would I sort this array so it prints the name with the most points first?
for testing am printing contents thus:
[FONT=Courier New]for (var i = 0; i < members.length; i++) {
$('#theMembers').append('name: ' + members[i].name +
' -- points: ' + members[i].points + '<br>' );
}
[/FONT]
but how do I sort it so the member with the most points prints first?
I know array has .sort() method, but how does it work for a more complex array like this one?
(is this an array of objects or a three-dimensional array? is it the same thing?
thank you…