human
How to swap a group of column headings with their values in Pandas
assistant
Here is some code to sort the values of the dataframe `df` and align the columns accordingly based on the obtained indices after np.argsort.

pd.DataFrame(df.columns[np.argsort(df.values)], df.index, np.unique(df.values))

#Warning: this code generation is experimental. Please inspect the code for any bugs before executing.