title: Sort list of strings in decreasing order (according to length)
body: <p>I'd like to sort a list of strings in decreasing order of their lengths. If there are 2 or more strings with the same length, the order should be lexicographical in ascending order.</p>
  
  <p><code>Input: ['a', 'bb', 'cc', 'ddd', 'bbc']</code></p>
  
  <p><code>Expected Output: ['bbc', 'ddd', 'bb', 'cc', 'a']</code></p>
  
  <p>In the above example, the list is ordered in decreasing order of the length of the strings. But since the length of the string 'bb' and 'cc' is the same, they are ordered lexicographically (in ascending order).</p>
  
  <p>The function I have is - </p>
  
  <p><code>sorted(sample_list, key=lambda x: (len(x), x), reverse=True)</code></p>
  
  <p>However, the <strong>x</strong> in the lambda function gives an additional parameter (in case the <code>len(x)</code> is same). But since I've set <code>reverse=True</code>, it sorts the string in decreasing lexicographical order instead of ascending (when the len(x) is equal).</p>
  
  <p><code>Observed output from above code: ['ddd', 'bbc', 'cc', 'bb', 'a']</code></p>
  
  <p>I don't know what change I can make in the lambda function to accommodate this condition.</p>
  
  <p>References:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/44414264/python-sort-string-by-frequency-cannot-sort-with-sorted-function">SO: Python Sort string by frequency - cannot sort with sorted() function</a></li>
  <li><a href="https://stackoverflow.com/questions/23429426/sorting-a-list-by-frequency-of-occurrence-in-a-list">SO: Sorting a List by frequency of occurrence in a list</a></li>
  </ul>