Python Programming - Lambda Functions - Discussion

Discussion Forum : Lambda Functions - General Questions (Q.No. 53)
53.
When using the sorted() function with a lambda function to sort a list of dictionaries, how can you sort based on a specific key within each dictionary?
sorted(dictionaries, lambda x: x['key'])
sorted(dictionaries, key=lambda x: x['key'])
sorted(dictionaries, sort_key=lambda x: x['key'])
sorted(dictionaries, key='key')
Answer: Option
Explanation:
The key parameter is used to specify the lambda function that extracts the specific key for sorting.
Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.