npm.io
0.0.1 • Published 12 years ago

find-insert-index

Licence
MIT
Version
0.0.1
Deps
0
Vulns
0
Weekly
0
Stars
2

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

Keywords