Hi so I have a list of class objects
list = [x, y, z]
but I want to sort them like integers ( they have a integer variable defined in them that I want to sort by(i access it by doing list[x].score)), but i don't know how to
could anyone show me how to sort this? (the list has variable length)
idealy something like this:
list = [x, y, z] # x.score = 2, y.score = 3, z.score = 1
list.sort() # or something
# list = [z, x, y]
source https://stackoverflow.com/questions/76142965/how-to-sort-list-of-classes-as-if-they-were-integers-in-python
Comments
Post a Comment