To sort a dictionary on values, all the answers I found use a lambda. Is it possible to use a function? I can't seem to get the values passed correctly.
sales = {
'north': 2,
'south': 6,
'east': 8,
'west': 7,
}
def get_value(collection,key): # substitue for lambda x: x[1]
return collection.get(key)
print(sales)
#sort_sales = sorted(sales.items(), key=lambda x: x[1]) # uses lambda
sort_sales = sorted(sales.items(), get_value( sales,sales.items() ) )
print(sort_sales)