* Uses a binary search to determine the smallest index at which a value * should be inserted into a given sorted array in order to maintain the sort * order of the array. If a callback is provided it will be executed for * `value` and each element of `array` to compute their sort rank
(array, value, callback, thisArg)
| 40035 | * // => 2 |
| 40036 | */ |
| 40037 | function sortedIndex(array, value, callback, thisArg) { |
| 40038 | var low = 0, |
| 40039 | high = array ? array.length : low; |
| 40040 | |
| 40041 | // explicitly reference `identity` for better inlining in Firefox |
| 40042 | callback = callback ? lodash.createCallback(callback, thisArg, 1) : identity; |
| 40043 | value = callback(value); |
| 40044 | |
| 40045 | while (low < high) { |
| 40046 | var mid = (low + high) >>> 1; |
| 40047 | (callback(array[mid]) < value) |
| 40048 | ? low = mid + 1 |
| 40049 | : high = mid; |
| 40050 | } |
| 40051 | return low; |
| 40052 | } |
| 40053 | |
| 40054 | /** |
| 40055 | * Creates an array of unique values, in order, of the provided arrays using |