-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
_.sortedIndex align with _.sortBy #1834
Comments
Ping #1768 |
@megawac I believe I have a solution to this problem, that would work in all cases, but it changes the function around just a bit... _.sortedIndex([1, 2, undefined, undefined], undefined);
// => 2 but the draw back to my solution is that for duplicate values in an array, it will give you the last index : _.sortedIndex([10, 20, 30, 40, 50], 30);
// => 3 it basically gives you #1882 but to my defense, the definition of the function in the docs still holds true:
Which does insert it into the list in order to maintain the list's sorted order. What do you think? |
If you would like to share a gist @arianf I would be interested in seeing
|
This is my old solution: https://gist.github.com/arianf/926c79e57d1779408cc9#file-orignal-solution-to-_-sortedindex I've updated my solution to work the original way for duplicate values, I am about to make a pull request. |
👍 Great work @arianf |
The text was updated successfully, but these errors were encountered: