df sort values

>>> df.sort_values(by=['col1'], ascending = False)
    col1 col2 col3
0   A    2    0
1   A    1    1
2   B    9    9
5   C    4    3
4   D    7    2
3   NaN  8    4

Here is what the above code is Doing:
1. We’re creating a DataFrame with three columns, col1, col2, and col3.
2. We’re setting the values of col1 to A, B, and C.
3. We’re setting the values of col2 to 1, 2, and 3.
4. We’re setting the values of col3 to 4, 5, and 6.
5. We’re sorting the DataFrame by the values in col1 in ascending order.
6. We’re displaying the DataFrame.

As you can see, the DataFrame is sorted by the values in col1.

Now, let’s sort the DataFrame by the values in col1 in descending order: