-
-
Save IndhumathyChelliah/3e02107d5146602242c412dd657819a4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
l1=[(1,2,3),(3,1,1),(8,5,3),(3,4,2)] | |
#Sorted based on second element in the tuple.lambda function returns second element in the tuple | |
print (sorted(l1,key=lambda x:x[1])) | |
#Output:[(3, 1, 1), (1, 2, 3), (3, 4, 2), (8, 5, 3)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment