code: function compareCompletions(a, b) {
      if (typeof a != "string") { a = a.name; b = b.name; }
      var aUp = /^[A-Z]/.test(a), bUp = /^[A-Z]/.test(b);
      if (aUp == bUp) return a < b ? -1 : a == b ? 0 : 1;
      else return aUp ? 1 : -1;
    }
docs: Built-in query types