31강 정렬
strs = ['aaaa', 'bb', 'ccc', 'd']
strs.sort(key=len)
print(strs)
nested_list = [[3, 2, 1], [6, 5, 4], [9, 8, 7]]
nested_list.sort(key=lambda x: x[1])
print(nested_list)
nested_list = [[3, 2, 1], [6, 5, 4], [9, 8, 7]]
for sublist in nested_list:
sublist.sort()
print(nested_list)
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
people = [Person('John', 20), Person('Jane', 19), Person('Adam', 21)]
people.sort(key=lambda x: x.age)
for person in people:
print(person)