How to Sort a List of Lists in Python

Опубликовано: 01 Октябрь 2024
на канале: Python Tutorials for Digital Humanities
5,063
70

If you enjoy this video, please subscribe. I provide all my content at no cost. If you want to support my channel, please donate via
PayPal: https://www.paypal.com/cgi-bin/webscr...
Patreon:   / wjbmattingly   (its my www.themedievalworld.com account as well).

If there's a specific video you would like to see or a tutorial series, let me know in the comments and I will try and make it.

If you liked this video, check out www.PythonHumanities.com, where I have Coding Exercises, Lessons, on-site Python shells where you can experiment with code, and a text version of the material discussed here.

###How to sort a list of lists in Python###

data = [
["Jim", 1988],
["Xena", 1940],
["Alexa", 1950],
["Bob", 1977],
["Jerry", 1990],
["Cindy", 1995]
]

data.sort(key=lambda x: x[1])

print (data)