<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_sorted_hdrgo2usrgos(self, hdrgos, flat_list=None, hdrgo_prt=True, hdrgo_sort=True):
 """Return GO IDs sorting using go2nt's namedtuple."""

        # Return user-specfied sort or default sort of header and user GO IDs
        sorted_hdrgos_usrgos = []
        h2u_get = self.grprobj.hdrgo2usrgos.get
        # Sort GO group headers using GO info in go2nt
        hdr_go2nt = self._get_go2nt(hdrgos)
        if hdrgo_sort is True:
            hdr_go2nt = sorted(hdr_go2nt.items(), key=lambda t: self.hdrgo_sortby(t[1]))
        for hdrgo_id, hdrgo_nt in hdr_go2nt:
            if flat_list is not None:
                if hdrgo_prt or hdrgo_id in self.grprobj.usrgos:
                    flat_list.append(hdrgo_nt)
            # Sort user GOs which are under the current GO header
            usrgos_unsorted = h2u_get(hdrgo_id)
            if usrgos_unsorted:
                usrgo2nt = self._get_go2nt(usrgos_unsorted)
                usrgont_sorted = sorted(usrgo2nt.items(), key=lambda t: self.usrgo_sortby(t[1]))
                usrgos_sorted, usrnts_sorted = zip(*usrgont_sorted)
                if flat_list is not None:
                    flat_list.extend(usrnts_sorted)
                sorted_hdrgos_usrgos.append((hdrgo_id, usrgos_sorted))
            else:
                sorted_hdrgos_usrgos.append((hdrgo_id, []))
        return cx.OrderedDict(sorted_hdrgos_usrgos)