There is a function called sort_values() which is very similar to "ORDER BY" of SQL. You can use it to sort the DataFrame by one column or multiple columns, in ascending or in descending order. By default, it sorts in ascending order. Check the following examples.
>>> import pandas as pd>>> df=pd.DataFrame({'Fruit':['banana','apple','orange','mango'], 'Price':[23,12,45,9], 'Stock':[3500,2300,4500,4200]})>>> df Fruit Price Stock0 banana 23 35001 apple 12 23002 orange 45 45003 mango 9 4200Sort by one column>>> df.sort_values(by=['Fruit']) Fruit Price Stock1 apple 12 23000 banana 23 35003 mango 9 42002 orange 45 4500Sort by mlutiple columns>>> df.sort_values(by=['Fruit','Price']) Fruit Price Stock1 apple 12 23000 banana 23 35003 mango 9 42002 orange 45 4500Sort in descending order>>> df.sort_values(by=['Fruit','Price'], ascending=False) Fruit Price Stock2 orange 45 45003 mango 9 42000 banana 23 35001 apple 12 2300