docs: function mongoCompare(a, b) {
    // TODO:  maybe faster to write this as a switch off of "typeof a/b" ?
  
    if (a === undefined) {
      if (b === undefined) {
        return 0;
      }
  
      return -1;
    } else if (b === undefined) {
      return 1;
    }
  
    if (a === null) {
      if (b === null) {
        return 0;
      }
  
      return -1;
    } else if (b === null) {
      return 1;
    }
  
    if (_.isNumber(a)) {
      if (_.isNumber(b)) {
        return a - b;
      }
  
      return -1;
    } else if (_.isNumber(b)) {
      return 1;
    }
  
    if (_.isString(a)) {
      if (_.isString(b)) {
        return a.localeCompare(b);
      }
  
      return -1;
    } else if (_.isString(b)) {
      return 1;
    }
  
    if (_.isObject(a) && !_.isDate(a)) {
      if (_.isObject(b) && !_.isDate(b)) {
        if (_.isEmpty(a)) {
          return _.isEmpty(b) ? 0 : -1;
        } else if (_.isEmpty(b)) {
          return 1;
        }
  
        for (const key of _.union(_.keys(a), _.keys(b)).sort()) {
          const av = a[key],
            bv = b[key];
  
          if (av === undefined) {
            return 1;
          } else if (bv === undefined) {
            return -1;
          }
  
          const v = mongoCompare(av, bv);
  
          if (v) {
            return v;
          }
        }
  
        return 0;
      }
  
      return -1;
    } else if (_.isObject(b) && !_.isDate(b)) {
      return 1;
    }
  
    if (_.isDate(a)) {
      if (_.isDate(b)) {
        return a.valueOf() - b.valueOf();
      }
  
      return -1;
    } else if (_.isDate(b)) {
      return 1;
    }
  
    // TODO:  what other cases are not being handled?
    if (a < b) {
      return -1;
    } else if (a > b) {
      return 1;
    }
  
    return 0;
  }