How to sort a list with two keys but one in reverse order?
<p>I was wondering what would be a Pythonic way of sorting a list of tuples by two keys whereby sorting with one (and only one) key would be in a reverse order and sorting with the the other would be case insensitive.
More specifically, I have a list containing tuples like:</p>
<pre><code>myList = [(ele1A, ele2A),(ele1B, ele2B),(ele1C, ele2C)]
</code></pre>
<p>I can use the following code to sort it with two keys:</p>
<pre><code>sortedList = sorted(myList, key = lambda y: (y[0].lower(), y[1]))
</code></pre>
<p>To sort in reverse order I can use</p>
<pre><code>sortedList = sorted(myList, key = lambda y: (y[0].lower(), y[1]), reverse = True)
</code></pre>
<p>But this would sort in a reverse order with two keys.</p>