I have a list of Objects of class Student
class Student:
def __init__(self,id,name,cgpa):
self.id=id
self.name=name
self.cgpa=cgpa
def __str__(self):
return "Id:{} Name:{} CGPA:{}".format(self.id,self.name,self.cgpa)
student_objects = [ Student(33,'Rumpa',3.68), Student(85,'Ashis',3.85), Student(56,'Samiha' 3.75), Student(19,'Samara',3.75), Student(22,'Fahim',3.76),]
Now I have to sort these student objects first with cgpa in DESCENDING order. If both have the same cgpa then order them using the name in ASCENDING order and if both have the same name, order them by using their ID which is unique for every student.
Generally for sorting i use sorted(Iterable,key='',reverse=''). But how can I add the CONDITION where I can go to the next step where if both have the same cgpa I can sort them by using their name.