WeCodeAcademy

Sorting and Ranking

sort_values('column') orders the rows (ascending=False for biggest first, a list of columns to break ties). nlargest(n, 'column') and nsmallest give the top or bottom rows directly.

Examplepython
Open in editor »
Quick check

How do you sort so the largest age comes first?

Your turn: write the code

Print the names of the two youngest people (nsmallest on age).

Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.

Tip: use the left and right arrow keys to move between lessons.