python
Published on January 26, 2024By DeveloperBreeze
# Define a dictionary
my_dict = {'apple': 3, 'banana': 1, 'cherry': 2}
# Sort the dictionary by values using a lambda function
sorted_dict = dict(sorted(my_dict.items(), key=lambda item: item[1]))
Comments
Please log in to leave a comment.