 <p><a href="http://docs.python.org/py3k/library/collections.html#counter-objects" rel="nofollow"><code>collections.Counter</code></a> exists for precisely this kind of work:</p> <pre><code>&gt;&gt;&gt; collections.Counter(i[1] for i in L).most_common() [(2, 2), (1, 1), (5, 1)] </code></pre>