Use sorted() with key as follows:
>>> unsorted_list = [['a','b','c','5','d'],['e','f','g','3','h'],['i','j','k','4','m']] >>> sorted(unsorted_list, key = lambda x: int(x[3])) [['e', 'f', 'g', '3', 'h'], ['i', 'j', 'k', '4', 'm'], ['a', 'b', 'c', '5', 'd']]
lambda returns the fourth element of each of the internal lists, and the sorted function uses this to sort the list. This assumes that int(elem) will not work for a list.
Or use itemgetter (as Ashwini commented, this method will not work if you have string representations of numbers, as they are tied to something for 2 + digits)
>>> from operator import itemgetter >>> sorted(unsorted_list, key = itemgetter(3)) [['e', 'f', 'g', '3', 'h'], ['i', 'j', 'k', '4', 'm'], ['a', 'b', 'c', '5', 'd']]