I have some elements in a list in one class. I want them sorted in a new list, and they have to be sorted by an attribute from another class.
Can anyone give an exa
To sort a list of objects that have the attribute bar:
bar
anewlist = sorted(list, key=lambda x: x.bar)