Command
Explanation
df.sort_values() sorts rows by column values, while df.sort_index() sorts by index.
Examples
Sort by column col1 ascending
Sort by column col1 descending
Sort by index
df.sort_values() sorts rows by column values, while df.sort_index() sorts by index.
Sort by column col1 ascending
Sort by column col1 descending
Sort by index