Created
August 18, 2014 21:32
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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