Match dissimilar items inside a list in python
<p>Whats the best way to match dissimilar items in a list in Python 2.7, I have </p>

<pre><code>list= [('A', 6L), ('B', 7L), ('C', 8L), ('D', 8L), ('E', 6L), ('F', 8L)]
</code></pre>

<p>And I want to match the result like this</p>

<pre><code>new list = ('A', 6L, 'B', 7L), ('C', 8L, 'E', 6L), ('D', 8L), ('F' 8L)] 
</code></pre>

<p>where any unmatched items are at the end of the list in this case D and F.</p>

<p>EDIT: By matching dissimilar I mean joining each tuple (e.g (A, 6)) with another tuple where the second item in the tuple (e.g. 6) is not the same. So (A,<strong>6</strong>) and (B,<strong>7</strong>) but not (A, <strong>6</strong>) and (E,<strong>6</strong>)</p>
