How can I sort a dictionary using the values from a list?
names = ['bread', 'banana', 'apple']
prices = ['2', '4', '1']
...
dict = {'name': names, 'price': prices}
dict
is now {'name': ['bread', 'banana', 'apple'], 'price': ['2', '4', '1']}
I want to sort the dictionary in a way that the first name corresponds to the lower price.
Is this possible to achieve with sorting on a dictionary?
Example
sorted_dict = {'name': ['apple', 'bread', 'banana'], price: ['1', '2', '4']}