title: Using sorted() in Python
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/8966538/syntax-behind-sortedkey-lambda">Syntax behind sorted(key=lambda :)</a>  </p>
  </blockquote>
  
  
  
  <p>I was going through the <a href="http://docs.python.org/howto/sorting.html" rel="noreferrer">documentation</a> and came across this example:</p>
  
  <pre><code>&gt; student_tuples = [
        ('john', 'A', 15),
        ('jane', 'B', 12),
        ('dave', 'B', 10), ]
  
  &gt; sorted(student_tuples, key=lambda student: student[2])  # sort by age 
  [('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]
  </code></pre>
  
  <p>What I don't understand is what are lambda and student here? Can they be replaced by any other names? And what the <code>:</code> do in <code>student:student[2]</code>? It's a little ambiguous since I've never come across this before.</p>