es2015/object-store/query-engine.js
function insertSorted(records, record, primaryKey, comparator) {
  let index = findInsertIndex(records, record, comparator)
  records.splice(index, 0, {
    record,
    primaryKey
  })
}
function insertSorted(records, record, primaryKey, comparator) {
  let index = findInsertIndex(records, record, comparator)
  records.splice(index, 0, {
    record,
    primaryKey
  })
}
Inserts the provided record into the sorted array of records and their
primary keys, keeping it sorted.

@param {{record: *, primaryKey: (number|string|Date|Array)}[]} records The
array of records into which the provided record should be inserted.
@param {*} record The record to insert into the records array.
@param {(number|string|Date|Array)} primaryKey The primary key of the
record.
@param {function(*, *): number} comparator Record comparator by which the
array is sorted. The comparator is a standard comparator function
compatible with the {@linkcode Array.prototype.sort} method.