Skip to content

Instantly share code, notes, and snippets.

@eyaltrabelsi
Created July 5, 2019 19:33
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 eyaltrabelsi/09c110fe2d28433e8890abb57fb93473 to your computer and use it in GitHub Desktop.
Save eyaltrabelsi/09c110fe2d28433e8890abb57fb93473 to your computer and use it in GitHub Desktop.
Python trick for getting sorted iterables
>>> a = [1, 2, -3]
>>> sorted(a)
[-3, 1, 2]
>>> sorted(a,key=abs)
[1, 2, -3]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment