> 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/sortedindex.md).

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

**语法：**

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

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

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

**描述：**

使用二进制的方式检索来确定`value`值，为了维持`array`的排序，插入到数组中尽可能小的索引位置并返回索引值。

> 会先进行排序

**开始版本：**&#x30;.1.0

**参数：**

* `array (Array)`: 要检查的排序数组。
* `value (*)`: 要评估的值。

**返回值：**

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

**例子：**

```javascript
_.sortedIndex([30, 50], 40);
// => 1
```
