Python sorting: Difference between revisions
From wikinotes
(Created page with " <source lang="python"> foo = sorted(['z', 'b', 'a']) # new copy sort(mylist) # mutates 'mylist' sorted(mylist, key=lambda x: x % 2) # sort by result of 'k...") |
(No difference)
|
Latest revision as of 16:11, 6 February 2021
foo = sorted(['z', 'b', 'a']) # new copy
sort(mylist) # mutates 'mylist'
sorted(mylist, key=lambda x: x % 2) # sort by result of 'key'