> For the complete documentation index, see [llms.txt](https://lodash.shujuwajue.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lodash.shujuwajue.com/array/sortedindexby.md).

# \_.sortedIndexBy（获取索引值）

**语法：**

```javascript
_.sortedIndexOf(array, value)
```

**源代码链接：**[source](https://github.com/lodash/lodash/blob/4.17.10/lodash.js#L7993)

**npm包链接：**[npm package](https://www.npmjs.com/package/lodash.sortedindexof)

**描述：**

这个方法类似[`_.sortedIndex`](https://lodash.com/docs/4.17.10#sortedIndex)，除了它接受一个`iteratee`（迭代函数），调用每一个数组（`array`）元素，返回结果和`value`值比较来计算排序。iteratee 会传入一个参数：*(value)*。

> 会先进行排序

**开始版本：**&#x34;.0.0

**参数：**

* `array (Array)`: 要检查的排序数组。
* `value (*)`: 要评估的值。
* `[iteratee=_.identity] (Array|Function|Object|string)`: 迭代函数，调用每个元素。

**返回值：**

* `(number)`: 返回 value值 应该在数组array中插入的索引位置 index。

**例子：**

```javascript
var objects = [{ 'x': 4 }, { 'x': 5 }];

_.sortedIndexBy(objects, { 'x': 4 }, function(o) { return o.x; });
// => 0

// The `_.property` iteratee shorthand.
_.sortedIndexBy(objects, { 'x': 4 }, 'x');
// => 0
```
