docs: function (doc) {
      var self = this;
      var minKey = null;
  
      self._generateKeysFromDoc(doc, function (key) {
        if (!self._keyCompatibleWithSelector(key))
          return;
  
        if (minKey === null) {
          minKey = key;
          return;
        }
        if (self._compareKeys(key, minKey) < 0) {
          minKey = key;
        }
      });
  
      // This could happen if our key filter somehow filters out all the keys even
      // though somehow the selector matches.
      if (minKey === null)
        throw Error("sort selector found no keys in doc?");
      return minKey;
    }