Python – How to sort a list of lists by the fourth element in each list?

StackOverflow

I would like to sort the following list of lists by the fourth element (the integer) in each individual list.

unsorted_list = [["a","b","c","5","d"],["e","f","g","3","h"],["i","j","k","4","m"]]

How can I do this? Thank you!

Answer rating: 200

unsorted_list.sort(key=lambda x: x[3])




Get Solution for free from DataCamp guru