JosefJezek
7/10/2014 - 10:24 AM

Python Sorting

Python Sorting

Python Sorting

Sublist

  • Sort list by sublist index 0

list.sort(key=lambda x: x[0])

More items

from operator import itemgetter
student_tuples = [
        ('john', 'A', 15),
        ('jane', 'B', 12),
        ('dave', 'B', 10),
]
sorted(student_tuples, key=itemgetter(1,2))