Honor roll by class
Your task
A school posts an honor roll per class. Each gradebook row is "class,student,score" (score a non-negative integer; one row per student per class). Given the rows and an integer n >= 1, return up to n rows per class, formatted exactly like the input: classes in ascending name order, and within a class students by score descending, ties broken by name ascending. Example: rows ["math,ava,91", "math,raj,88", "math,mia,95", "art,leo,70"] with n=2 give ["art,leo,70", "math,mia,95", "math,ava,91"].
Examples
honor_roll(rows: list[str], n: int) -> list[str]Example 1
Input
honor_roll(["math,ava,91", "math,raj,88", "math,mia,95", "art,leo,70"], 2)Output
["art,leo,70", "math,mia,95", "math,ava,91"]