code: function compareByIdThenRev(a, b) {
    var idCompare = compare(a._id, b._id);
    if (idCompare !== 0) {
      return idCompare;
    }
    var aStart = a._revisions ? a._revisions.start : 0;
    var bStart = b._revisions ? b._revisions.start : 0;
    return compare(aStart, bStart);
  }
docs: compare two docs, first by _id then by _rev