21 lines
396 B
Python
Executable File
21 lines
396 B
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
class Person():
|
|
def __init__(self, name, age):
|
|
self.name = name
|
|
self.age = age
|
|
|
|
def __repr__(self):
|
|
return repr((self.name, self.age))
|
|
|
|
|
|
people = [
|
|
Person("tom", 22),
|
|
Person("jack", 11),
|
|
Person("jerry", 33)
|
|
]
|
|
|
|
if __name__ == "__main__":
|
|
sorted_people = sorted(people, key=lambda person: person.age)
|
|
print(sorted_people)
|