Last active
December 8, 2018 05:33
-
-
Save MineRobber9000/0e14cddcf55fd6e83aafda69749509f8 to your computer and use it in GitHub Desktop.
MRANK function for Google Sheets
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 MRANK(value,values) { | |
var values = values.map(function(x) { return x[0]; }); // apparently I misjudged how Google Sheets passes values. Why is it like this?!?! | |
var valuesSorted = values.sort(function(a,b){ return b-a; }); | |
var valuesUnique = valuesSorted.filter(function(value,index,self) { return self.indexOf(value) === index; }); | |
var index = valuesUnique.indexOf(value); | |
if (index<0) { | |
throw("MRANK has no valid input data"); | |
} | |
return index+1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment