code: def sort_dataframe_cols(self):
          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 = []
          try:
              names = sorted_cols.pop('Names')
          except KeyError:
              names = []
          ordered_cols.extend(list(names))
          no_group = []
          if '' in sorted_cols:
              no_group = sorted_cols.pop('')
          for k in sorted(sorted_cols):
              ordered_cols.extend(sorted(sorted_cols[k]))
          ordered_cols.extend(no_group)
          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