🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
## sortedIndexBy + [link](./sortedIndexBy "Link to this entry.") + [source](https://github.com/lodash/lodash/blob/4.5.0正式版/lodash.src.js#L6482 "View in source.") + [npm](https://www.npmjs.com/package/lodash.sortedindexby "See the npm package.") ``` _.sortedIndexBy(array, value, [iteratee=_.identity]) ``` 这个方法类似 `_.sortedIndex`,除了它接受一个 iteratee 调用每一个数组和值来计算排序。iteratee 会传入一个参数:(value)。 ### 参数 1. array (Array) 需要检索的已排序数组 2. value (\*) 要评估位置的值 3. [iteratee=_.identity] (Function|Object|string) 这个函数会处理每一个元素 ### 返回值 (number) 返回 value 应该在数组中插入的 index。 ### 示例 ``` var dict = { 'thirty': 30, 'forty': 40, 'fifty': 50 }; _.sortedIndexBy(['thirty', 'fifty'], 'forty', _.propertyOf(dict)); // => 1 // 使用了 `_.property` 回调结果 _.sortedIndexBy([{ 'x': 4 }, { 'x': 5 }], { 'x': 4 }, 'x'); // => 0 ```