Skip to content

sortedIndex

js
_.sortedIndex(array, value)

使用二进制搜索来确定应将 value 插入 array 的最低索引,以保持其排序顺序。

¥Uses a binary search to determine the lowest index at which value should be inserted into array in order to maintain its sort order.

新增于

¥Since

0.1.0

参数

¥Arguments

  1. array (数组):要检查的排序数组。

    ¥array (Array): The sorted array to inspect.

  2. value (*):要评估的值。

    ¥value ()*: The value to evaluate.

返回

¥Returns

(数值):返回应将 value 插入 array 的索引。

¥(number): Returns the index at which value should be inserted into array.

示例

¥Example

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

Lodash v4.17 中文网 - 粤ICP备13048890号