Home » Education » How to Sort a List of Lists in Python

How to Sort a List of Lists in Python

Written By Python Tutorials for Digital Humanities on Saturday, Apr 18, 2020 | 11:01 AM

 
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?cmd=_donations&business=AZ73QW52SUX8N&currency_code=USD&source=url Patreon: https://www.patreon.com/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)