Skip to content
Minsing Log
Go back

English Edition

About the sorted() parameter key and lambda values

Programming & CS

Conclusion

Sort values based on a lambda function. I guess I should learn by looking at the examples.

Parameter Groups

key

Ascending order: sorted(a, key=lambda x:x[0]) Descending order: sorted(a, key=lambda x:-x[0])

reverse

True: Descending order (the numbers get smaller) False(default): Ascending order

Confusing Examples

Source

Follow the journey

Get new posts by email.

Short, honest notes on building, startups, learning, failures, and retrospectives, for readers who follow the journey rather than pass through from search.

The newsletter is coming soon. Until then, follow via RSS or email me to get notified.


Share this post:

Comments

Sign in with GitHub to leave a comment.


Previous Post
Dictionary.pop(Key)
Next Post
What is yield? (feat. generators)