I see it used in sorting, but what do the individual components of this line of code actually mean?
key=lambda x: x[1]
What\'s lambda
lambda
student_tuples = [ ('john', 'A', 15), ('jane', 'B', 12), ('dave', 'B', 10),] sorted(student_tuples, key=lambda student: student[2]) # sort by age >>>>[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]
from official documentation