Skip to content

Instantly share code, notes, and snippets.

@keithxm23
Created August 18, 2014 21:32
Show Gist options
  • Save keithxm23/f94c41f4e1542160d6ba to your computer and use it in GitHub Desktop.
Save keithxm23/f94c41f4e1542160d6ba to your computer and use it in GitHub Desktop.
Code to parse injuries and count for each player from: http://www.physioroom.com/news/english_premier_league/clubs/1/arsenal_injuries.html
var players = {}
$("table#clubplayer > tbody > tr:not(:first-child) > td:first-child > a").each(function(){
console.log(players);
var player = $(this).text();
if (player in players){
players[player] += 1;
}
else{
players[player] = 1;
}
})
var sortable = [];
for (var p in players)
sortable.push([p, players[p]])
sortable.sort(function(a, b) {return b[1] - a[1]})
for (var i = 0; i < sortable.length; i++) {
console.log(sortable[i]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment