Return grouped, sorted namedtuples in either format: flat, sections.

def get_desc2nts_fnc(self, hdrgo_prt=True, section_prt=None,
                         top_n=None, use_sections=True):
        """Return grouped, sorted namedtuples in either format: flat, sections."""
        # RETURN: flat list of namedtuples
        nts_flat = self.get_nts_flat(hdrgo_prt, use_sections)
        if nts_flat:
            flds = nts_flat[0]._fields
            if not use_sections:
                return {'sortobj':self, 'flat' : nts_flat, 'hdrgo_prt':hdrgo_prt, 'flds':flds,
                        'num_items':len(nts_flat), 'num_sections':1}
            else:
                return {'sortobj':self,
                        'sections' : [(self.grprobj.hdrobj.secdflt, nts_flat)],
                        'hdrgo_prt':hdrgo_prt,
                        'flds':flds,
                        'num_items':len(nts_flat), 'num_sections':1}
        # print('FFFF Sorter:get_desc2nts_fnc: nts_flat is None')
        # RETURN: 2-D list [(section_name0, namedtuples0), (section_name1, namedtuples1), ...
        #     kws: top_n hdrgo_prt section_sortby
        # Over-ride hdrgo_prt depending on top_n value
        assert top_n is not True and top_n is not False, \
            "top_n({T}) MUST BE None OR AN int".format(T=top_n)
        assert self.sectobj is not None, "SECTIONS OBJECT DOES NOT EXIST"
        sec_sb = self.sectobj.section_sortby
        # Override hdrgo_prt, if sorting by sections or returning a subset of GO IDs in section
        hdrgo_prt_curr = hdrgo_prt is True
        if sec_sb is True or (sec_sb is not False and sec_sb is not None) or top_n is not None:
            hdrgo_prt_curr = False
        # print('GGGG Sorter:get_desc2nts_fnc: hdrgo_prt_curr({}) sec_sb({}) top_n({})'.format(
        #     hdrgo_prt_curr, sec_sb, top_n))
        nts_section = self.sectobj.get_sorted_nts_keep_section(hdrgo_prt_curr)
        # print('HHHH Sorter:get_desc2nts_fnc: nts_section')
        # Take top_n in each section, if requested
        if top_n is not None:
            nts_section = [(s, nts[:top_n]) for s, nts in nts_section]
            if section_prt is None:
                nts_flat = self.get_sections_flattened(nts_section)
                flds = nts_flat[0]._fields if nts_flat else []
                return {'sortobj':self, 'flat' : nts_flat, 'hdrgo_prt':hdrgo_prt_curr, 'flds':flds,
                        'num_items':len(nts_flat), 'num_sections':1}
        # Send flat list of sections nts back, as requested
        if section_prt is False:
            nts_flat = self.get_sections_flattened(nts_section)
            flds = nts_flat[0]._fields if nts_flat else []
            return {'sortobj':self, 'flat' : nts_flat, 'hdrgo_prt':hdrgo_prt_curr, 'flds':flds,
                    'num_items':len(nts_flat),
                    'num_sections':len(nts_section)}
        # Send 2-D sections nts back
        # print('IIII Sorter:get_desc2nts_fnc: nts_section')
        flds = nts_section[0][1][0]._fields if nts_section else []
        return {'sortobj':self, 'sections' : nts_section, 'hdrgo_prt':hdrgo_prt_curr, 'flds':flds,
                'num_items':sum(len(nts) for _, nts in nts_section),
                'num_sections':len(nts_section)}