Drills tagged with this skill, unpassed first. Pass them all to mark the skill ready for scenarios.
sort_by_revenue_desc(df) that returns the DataFrame sorted by revenue in descending order.
Example. revenues [150, 50, 200, 100] → reordered as 200, 150, 100, 50.
Notes. Stable sort — equal revenues keep their original relative order. Empty df → empty df.top_n(df, n) that returns the n rows with the largest values in the sales column, ordered from highest to lowest.
Example. 5 products, n=3 → top 3 by sales.
Notes. n larger than the df → returns all rows in sorted order. n=0 → empty DataFrame.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.