Sort and Reorder in Python

From the Pandas cheat sheet ยท Operations and Sorting ยท verified Aug 2026

Sort and Reorder

Sort rows or control column order.

python
df = df.sort_values("score", ascending=False)
๐Ÿ“Œ Each sort key can have its own direction
๐Ÿ’ก na_position controls missing placement
๐Ÿ” sort_index orders row or column labels
๐ŸŽฏ Assign or chain methods to keep the result
sortingordercolumns

Continue with Pandas

Save the full cheat sheet or work through every related task.

More Python tasks

Back to the full Pandas cheat sheet