Run ❯
×
Change Orientation
Change Theme, Dark/Light
Go to Spaces
def myFunc(e): return e['year'] cars = [ {'car': 'Ford', 'year': 2005}, {'car': 'Mitsubishi', 'year': 2000}, {'car': 'BMW', 'year': 2019}, {'car': 'VW', 'year': 2011} ] cars.sort(key=myFunc) print(cars)
[{'car': 'Mitsubishi', 'year': 2000}, {'car': 'Ford', 'year': 2005}, {'car': 'VW', 'year': 2011}, {'car': 'BMW', 'year': 2019}]