BuildlyBuildly
DashboardExercisesProfileHelp
Data Science/Module 2: Data Analytics/Sort & Rank3/3
Exercise·7 min·10 XP

Sort by Multiple Columns

Context. Order students by grade (A → F), then alphabetically by name within each grade.

Your task. Write sort_grade_then_name(df) that returns the DataFrame sorted by grade ascending, then name ascending.

Example. grades [B, A, A, B], names [Bob, Alice, Cher, Dan] → Alice/A, Cher/A, Bob/B, Dan/B.

Notes. grade is the primary key; name is the tiebreaker. Empty df → empty df.

Previous
Top N by Column
Next
Inner Join Two Tables