Skip to content

Instantly share code, notes, and snippets.

@IndhumathyChelliah
Created June 24, 2020 02:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IndhumathyChelliah/9873703027f2d241ad85708814b66a70 to your computer and use it in GitHub Desktop.
Save IndhumathyChelliah/9873703027f2d241ad85708814b66a70 to your computer and use it in GitHub Desktop.
#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