Created
October 18, 2016 18:41
-
-
Save a-eid/1f71082f96fec456c89379c1304ea6eb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function sortByRanking(rankingArray){ | |
function compare(a,b) { | |
if (a.ranking < b.ranking) | |
return -1; | |
if (a.ranking > b.ranking) | |
return 1; | |
return 0; | |
} | |
return rankingArray.sort(compare) | |
} | |
function avgRanking(rankingArray){ | |
return rankingArray.reduce(function(memo , next){ | |
return memo + next.ranking | |
} , 0) / rankingArray.length | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment