Solución
solution.tsTypeScript
from functools import total_ordering
@total_ordering
class Student:
def __init__(self, name, grade):
self.name = name
self.grade = grade
def __eq__(self, other) -> bool:
# Compara por calificación
return (self.grade == other.grade)
def __lt__(self, other) -> bool:
# Determina si este estudiante tiene calificación menor
return (self.grade < other.grade)
def rank_students(students):
objs = [Student(s["name"], s["grade"]) for s in students]
return [s.name for s in sorted(objs)]0respuestas