Skip to content

Instantly share code, notes, and snippets.

@JackInTaiwan
Created November 21, 2018 10:58
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 JackInTaiwan/211f2cb0df1c7b51c59e6747ffdcdad1 to your computer and use it in GitHub Desktop.
Save JackInTaiwan/211f2cb0df1c7b51c59e6747ffdcdad1 to your computer and use it in GitHub Desktop.
prices = [
("ice cream", 80),
("bike", 20000),
("water", 30),
]
sorted_by_price = sorted(prices, key=lambda x: x[1])
print(sorted_by_price)
# > [('water', 30), ('ice cream', 80), ('bike', 20000)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment