title: Sorting A List Comprehension In One Statement
body: <p>I noticed something I didn't expect when writing a script this morning. I tried to use a list comprehension and sort it all in one statement and got a surprising result. The following code summarizes my general use case, but is simplified for this question:</p>
  
  <pre><code>Transaction = namedtuple('Transaction', ['code', 'type'])
  
  my_list = [Transaction('code1', 'AAAAA'), Transaction('code2', 'BBBBB'), Transaction('code3', 'AAAAA')]
  
  types = ['AAAAA', 'CCCCC']
  
  result = [trans for trans in my_list if trans.type in types].sort(key = lambda x: x.code)
  
  print result
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>None
  </code></pre>
  
  <p>If I create the list using the comprehension, then sort it after the fact, everything is fine. I'm curious why this happens?</p>