def _init_grouping(self, elts):
        """
        Divide a given a list of APIDoc objects into groups, as
        specified by L{self.group_specs}.

        @param elts: A list of tuples C{(name, apidoc)}.
        
        @return: A list of tuples C{(groupname, elts)}, where
        C{groupname} is the name of a group and C{elts} is a list of
        C{APIDoc}s in that group.  The first tuple has name C{''}, and
        is used for ungrouped elements.  The remaining tuples are
        listed in the order that they appear in C{self.group_specs}.
        Within each tuple, the elements are listed in the order that
        they appear in C{api_docs}.
        """
        # Make the common case fast.
        if len(self.group_specs) == 0:
            return {'': [elt[1] for elt in elts]}

        ungrouped = set([elt_doc for (elt_name, elt_doc) in elts])
        groups = {}
        for (group_name, elt_names) in self.group_specs:
            group_re = re.compile('|'.join([n.replace('*','.*')+'$'
                                            for n in elt_names]))
            group = groups.get(group_name, [])
            for elt_name, elt_doc in list(elts):
                if group_re.match(elt_name):
                    group.append(elt_doc)
                    if ungrouped in elt_doc:
                        ungrouped.remove(elt_doc)
                    else:
                        # [xx] might just be listed in the same group twice!
                        log.warning("%s.%s is in multiple groups" %
                                    (self.canonical_name, elt_name))
            groups[group_name] = group

        # Convert ungrouped from an unordered set to an ordered list.
        groups[''] = [elt_doc for (elt_name, elt_doc) in elts
                      if elt_doc in ungrouped]
        return groups
dataset/ETHPy150Open ardekantur/pyglet/tools/epydoc/epydoc/apidoc.py/NamespaceDoc._init_grouping/swapped operands of `in`