Created
March 19, 2017 03:24
-
-
Save lachlan-eagling/c1ac4a7af4cd1bb33949b3532d14dbb6 to your computer and use it in GitHub Desktop.
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
// Searches for index to insert given parameter into array in ascending order. | |
function getIndexToIns(arr, num) { | |
arr.sort(function(x, y){ | |
return x > y; | |
}); | |
for(var i = 0; i < arr.length; i++){ | |
if(num <= arr[i]){ | |
return i; | |
} | |
} | |
return arr.length; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment