Python Programming - Lambda Functions - Discussion

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

Post your comments here:

Your comments will be displayed after verification.