Is there a way to sort a two-dimensional list on the values of the second 'column'?

For example, in the Python Lists Project, I have created a two-dimensional list by joining the names and insurance costs, in that order. Is it possible to sort the list by the insurance cost? Thanks :slight_smile:

link: https://www.codecademy.com/journeys/data-scientist-ml/paths/dsmlcj-22-data-science-foundations/tracks/dsmlcj-22-python-fundamentals-for-data-science-part-i/modules/dsf-python-lists-0fe2ec39-68f4-4899-975a-71e76552d627/projects/ds-python-lists2-project

Use the index of the second column as key

data = #2d list
sorted_by_second_column = sorted(data, key=lambda x: x[1])
2 Likes