nodes: 0, module; 1, function_definition; 2, function_name:_query_attr_sort_fn; 3, parameters; 4, block; 5, identifier:self; 6, identifier:attr_val; 7, expression_statement; 8, expression_statement; 9, if_statement; 10, comment:"""Used to order where keys by most selective key first"""; 11, assignment; 12, comparison_operator:attr in self._indexes; 13, block; 14, else_clause; 15, pattern_list; 16, identifier:attr_val; 17, identifier:attr; 18, attribute; 19, expression_statement; 20, if_statement; 21, block; 22, identifier:attr; 23, identifier:v; 24, identifier:self; 25, identifier:_indexes; 26, assignment; 27, comparison_operator:v in idx; 28, block; 29, else_clause; 30, return_statement; 31, identifier:idx; 32, subscript; 33, identifier:v; 34, identifier:idx; 35, return_statement; 36, block; 37, float:1e9; 38, attribute; 39, identifier:attr; 40, call; 41, return_statement; 42, identifier:self; 43, identifier:_indexes; 44, identifier:len; 45, argument_list; 46, integer:0; 47, subscript; 48, identifier:idx; 49, identifier:v
code: def _query_attr_sort_fn(self, attr_val):
          """Used to order where keys by most selective key first"""
          attr, v = attr_val
          if attr in self._indexes:
              idx = self._indexes[attr]
              if v in idx:
                  return len(idx[v])
              else:
                  return 0
          else:
              return 1e9