<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def sort_dataframe_cols(self):
 """ Sort self.df so that self.name is the first column, and the rest of the columns are sorted by group. """

        # get the group for each column
        cols = self.df.columns
        groups = list(map(lambda x: self.data_model.get_group_for_col(self.dtype, x), cols))
        sorted_cols = cols.groupby(groups)
        ordered_cols = []
        # put names first
        try:
            names = sorted_cols.pop('Names')
        except KeyError:
            names = []
        ordered_cols.extend(list(names))
        no_group = []
        # remove ungrouped columns
        if '' in sorted_cols:
            no_group = sorted_cols.pop('')
        # flatten list of columns
        for k in sorted(sorted_cols):
            ordered_cols.extend(sorted(sorted_cols[k]))
        # add back in ungrouped columns
        ordered_cols.extend(no_group)
        # put name first
        try:
            if self.name in ordered_cols:
                ordered_cols.remove(self.name)
                ordered_cols[:0] = [self.name]
        except AttributeError:
            pass
        #
        self.df = self.df[ordered_cols]
        return self.df