Список сортировки по ключам и значению
# dictionary sort by key and value
d = { ' a ' : 4, ' b ' : 3, ' c ' : 2, ' d ' : 1 }
sort_by_key= sorted(d.items(), key = lambda x : x[0] ) # [(' a ', 4), (' b ', 3), (' c ', 2), (' d ', 1)]
sort_by_value= sorted(d.items(), key = lambda x : x[1] ) # [(' d ', 1), (' c ', 2), (' b ', 3), (' a ', 4)]
print(sort_by_key)
print(sort_by_value)
Impossible Impala