find-insert-index
Version:
Find the index to insert an element in array keeping the sort order.
19 lines (14 loc) • 461 B
Markdown
find-insert-index
=================
Find the index to insert an element in array keeping the sort order.
[](https://travis-ci.org/joaonuno/find-insert-index-js)
# 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
```