Sorting the tuples of tuples in alphabetical order
<p>I have a list of tuples<br>
<code>[((A,B),2),((C,B),3)]</code>
Which I need to sort as</p>

<pre><code>[((A,B),2),((B,C),3)]
</code></pre>

<p>I need all the tuples to be in alphabetical order using the <code>sorted()</code> method. I have used <code>key = lambda x : x[0]</code> but doesn't work. Any ideas?</p>

<pre><code>l = [(('A','B'),2),(('C','B'),3)]
f=[(tuple(sorted(x[0])),x[1]) for x in l]
</code></pre>

<p>Output :</p>

<pre><code>[(('A', 'B'), 2), (('B', 'C'), 3)]
</code></pre>

python python-3.x