1#Python, Pandas
2#Sorting dataframe df on the values of a column col1
3#Temporary
4df.sort_values(by=["col1"]) 
5
6#Permanent
7df.sort_values(by=["col1"], inplace = True)1>>> df.sort_values(by=['col1'], ascending = False)
2    col1 col2 col3
30   A    2    0
41   A    1    1
52   B    9    9
65   C    4    3
74   D    7    2
83   NaN  8    4
91>>> df.sort_values(by=['col1'])
2    col1 col2 col3
30   A    2    0
41   A    1    1
52   B    9    9
65   C    4    3
74   D    7    2
83   NaN  8    4
91>>> df.sort_values(by='col1', ascending=False)
2  col1  col2  col3 col4
34    D     7     2    e
45    C     4     3    F
52    B     9     9    c
60    A     2     0    a
71    A     1     1    B
83  NaN     8     4    D
91#following is example of sorting by the column "2" in descending order
2final_df = df.sort_values(by=['2'], ascending=False)