Possible Duplicate:
Syntax behind sorted(key=lambda :)
I was going through the documentation and came across this example:
> 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)]
What I don't understand is what are lambda and student here? Can they be replaced by any other names? And what the :
do in student:student[2]
? It's a little ambiguous since I've never come across this before.