This method is like _.sortedIndex except that it accepts iteratee which is invoked for value and each element of array to compute their sort ranking. The iteratee is invoked with one argument: (value).
_.sortedIndex
iteratee
value
array
The sorted array to inspect.
The value to evaluate.
Optional
The iteratee invoked per element.
Returns the index at which value should be inserted into array.
var dict = { 'thirty': 30, 'forty': 40, 'fifty': 50 };_.sortedIndexBy(['thirty', 'fifty'], 'forty', _.propertyOf(dict));// => 1// using the `_.property` iteratee shorthand_.sortedIndexBy([{ 'x': 4 }, { 'x': 5 }], { 'x': 4 }, 'x');// => 0 Copy
var dict = { 'thirty': 30, 'forty': 40, 'fifty': 50 };_.sortedIndexBy(['thirty', 'fifty'], 'forty', _.propertyOf(dict));// => 1// using the `_.property` iteratee shorthand_.sortedIndexBy([{ 'x': 4 }, { 'x': 5 }], { 'x': 4 }, 'x');// => 0
This method is like
_.sortedIndex
except that it acceptsiteratee
which is invoked forvalue
and each element ofarray
to compute their sort ranking. The iteratee is invoked with one argument: (value).