Skip to content

Instantly share code, notes, and snippets.

@cemkaplan75
Created January 19, 2024 03:01
Show Gist options
  • Save cemkaplan75/b1053266d967f1ffc84f70b7f5d1d518 to your computer and use it in GitHub Desktop.
Save cemkaplan75/b1053266d967f1ffc84f70b7f5d1d518 to your computer and use it in GitHub Desktop.
# Data
beer_data = [
("Australia", 109.9),
("Austria", 108.3),
("Belgium", 93.0),
("Croatia", 81.2),
("Czech Republic", 156.9),
("Denmark", 89.9),
("Estonia", 104.0),
("Finland", 85.0),
("Germany", 115.8),
("Hungary", 75.3),
("Ireland", 131.3),
("Lithuania", 89.0),
("Luxembourg", 84.5),
("Netherlands", 79.0),
("New Zealand", 77.0),
("Romania", 90.0),
("Slovakia", 84.1),
("Spain", 83.8),
("United Kingdom", 99.0),
("United States", 81.6),
]
# Sorting by Per Capita Beer Consumption in descending order
sorted_beer_data = sorted(beer_data, key=lambda x: x[1], reverse=True)
# Print sorted data
for country, consumption in sorted_beer_data:
print(f"{country}: {consumption} L/Yr")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment