title: Python - sort a list of nested lists
body: <p>I have input consisting of a list of nested lists like this:</p>
  
  <pre><code>l = [[[[[39]]]], [1, 2, 3], [4, [5, 3], 1], [[[[8, 9], 10], 11], 12]]
  </code></pre>
  
  <p>I want to sort this list based on the sum of all the numbers in the nested lists... so, the values I want to sort by of l would look like this:</p>
  
  <pre><code>[39, 6, 13, 50]
  </code></pre>
  
  <p>Then I want to sort based on these. So the output should be:</p>
  
  <pre><code>[[1, 2, 3], [4, [5, 3], 1], [[[[39]]]], [[[[8, 9], 10], 11], 12]]
  </code></pre>
  
  <p>What's a nice pythonic way of doing this?</p>