-
-
Save IndhumathyChelliah/9873703027f2d241ad85708814b66a70 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
#Sorting list based on absolute value | |
l1=[1,-4,5,-7,9,2] | |
print (sorted(l1,key=abs)) | |
#Output:[1, 2, -4, 5, -7, 9] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment