title: Custom sort of a list of tuples
body: <p>I only started learning Python few days ago, and I wanted to implement my little project in it. I need to sort a list of <code>(string, integer)</code> in a descending order by the number value, but alphabetically if the number is the same for more than one tuple. So I have a list, say:</p>
  
  <pre><code>tuples = [('ggg', 5), ('aaa', 5), ('bbb', 6), ('zzz', 6)]
  tuples.sort(key=lambda score: score[1], reverse=True)
  </code></pre>
  
  <p>This returns:</p>
  
  <pre><code>[('bbb', 6), ('zzz', 6), ('ggg', 5), ('aaa', 5)]
  </code></pre>
  
  <p>But what I want to get is:</p>
  
  <pre><code>[('bbb', 6), ('zzz', 6), ('aaa', 5), ('ggg', 5)]
  </code></pre>
  
  <p>In Java I just implemented a comparator for a custom tuple:</p>
  
  <pre><code>class Pair {
      public final String s;
      public final Integer i;
  
      public Pair(String s, Integer i) {
          this.s = s;
          this.i = i;
      }
  }
  
  class PairComparator implements Comparator&lt;Pair&gt; {
  
      @Override
      public int compare(Pair p1, Pair p2) {
          int c = p1.i.compareTo(p2.i);
          return (c == 0) ? p1.s.compareTo(p2.s) : c * (-1);
      }
  }
  </code></pre>
  
  <p>But I'm not sure how to go about doing that in a <code>lambda</code> expression in Python.</p>