Multi-Column Sort

easypandas_exploration

Implement sort_by_surname_age(df).

df has columns 'name', 'surname', 'age'. Sort by two keys:

  1. surname — descending (Z → A)
  2. age — ascending (younger first) among rows sharing the same surname

Keep the original index; do not reset it.

# surname "Smith" > "Brown", so Smiths come first
# among Smiths: Carol (age 20) before Alice (age 30)
sort_by_surname_age(df)
# Carol  Smith 20
# Alice  Smith 30
# Bob    Brown 25

Your solution

Edit sort_by_surname_age and run the real pytest suite in your browser — no install required. Your code is saved locally.

⌘/Ctrl + ↵

Loading the Python runtime (first run only)…

Hints

Hint 1

df.sort_values(by=[...], ascending=[...]) accepts a list of column names and a matching list of booleans.

Hint 2

ascending=[False, True] means first column descending, second column ascending.