if I run this programm in order to sort my list after the attribute "name", I only receive this:
[<__main__.Gericht object at 0x00000190D292FE50>, <__main__.Gericht object at 0x00000190D292FD90>, <__main__.Gericht object at 0x00000190D292FEB0>, <__main__.Gericht object at 0x00000190D292FDF0>]
Could you help me to get the real results?
class Gericht:
def __init__(self, name, preis, calories, alergene = []):
self.name = name
self.preis = preis
self.calories = calories
self.alergene = alergene
def sortbyName(input):
sort = sorted(input, key=lambda gericht: gericht.name)
return sort
speisekarte = [Gericht("Spaghetti", 7.5, 750, [1, "a"]), Gericht("Brotstulle", 3, 250, []), Gericht("Tofu", 13, 634, [1, 2, 3, "b"]), Gericht("Eis", 1, 120, ["c", "d"]) ]
print(sortbyName(speisekarte))