Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

find-insert-index

joaonuno125.3kMIT0.0.1

Find the index to insert an element in array keeping the sort order.

find, array, index, sort, stable

readme

find-insert-index

Find the index to insert an element in array keeping the sort order.

Build Status

Example

var findInsertIndex, comparatorFn;
findInsertIndex = require('find-insert-index');
comparatorFn = function (a, b) {
  return a.id - b.id;
};

findInsertIndex(comparatorFn, [{id: 7}, {id: 8}], {id: 7});
// 1