Group multiple students
Input
group_by_grade([('Alice', 90), ('Bob', 80), ('Charlie', 90)])
Output
{80: ['Bob'], 90: ['Alice', 'Charlie']}
Bob has 80; Alice and Charlie have 90. Names within each grade are sorted; keys are ordered ascending.
Full lesson preview
Organize a list of (name, grade) pairs into a dictionary mapping each grade to the sorted list of student names.
Problem statement
Task
Examples
Input
group_by_grade([('Alice', 90), ('Bob', 80), ('Charlie', 90)])
Output
{80: ['Bob'], 90: ['Alice', 'Charlie']}
Bob has 80; Alice and Charlie have 90. Names within each grade are sorted; keys are ordered ascending.
Input format
Output format
Constraints
Samples
Input
group_by_grade([('Zoe', 70), ('Ann', 70)])
Output
{70: ['Ann', 'Zoe']}
Both students have grade 70; names sorted alphabetically.