The sortedIndex
function from Lodash is used to find the index at which a value should be inserted into an array in order to maintain the array's sorted order. Here is an example usage:
index.tsx161 chars7 lines
In the example above, the sortedIndex
function is passed an array and a value to insert, and it returns the index at which the value should be inserted in order to maintain the array's sorted order. The output shows that if we want to insert the value 25
into the array, it should be inserted at index 2
to maintain the sorted order. Similarly, if we want to insert the value 35
, it should be inserted at index 3
.
gistlibby LogSnag