title: How to sort list of dictrionaries in the right way Python
body: <p>I have list as follows:</p>
  
  <pre><code>data = [
    {'items': [
      {'key': u'3', 'id': 1, 'name': u'Typeplaatje'},
      {'key': u'2', 'id': 2, 'name': u'Aanduiding van het chassisnummer '},
      {'key': u'1', 'id': 3, 'name': u'Kilometerteller: Kilometerstand '},
      {'key': u'5', 'id': 4, 'name': u'Inschrijvingsbewijs '},
      {'key': u'4', 'id': 5, 'name': u'COC of gelijkvormigheidsattest '}
    ], 'id': 2, 'key': u'B', 'name': u'Onderdelen'},
    {'items': [
      {'key': u'10', 'id': 10, 'name': u'Koppeling'},
      {'key': u'7', 'id': 11, 'name': u'Differentieel '},
      {'key': u'9', 'id': 12, 'name': u'Cardanhoezen '},
      {'key': u'8', 'id': 13, 'name': u'Uitlaat '},
      {'key': u'6', 'id': 15, 'name': u'Batterij'}
      ], 'id': 2, 'key': u'B', 'name': u'Onderdelen'}
  ]
  </code></pre>
  
  <p>And I want to sort <code>items</code> by <code>key</code>.</p>
  
  <p>Thus the wanted result is as follows:</p>
  
  <pre><code>res = [
        {'items': [
          {'key': u'1', 'id': 3, 'name': u'Kilometerteller: Kilometerstand '},
          {'key': u'2', 'id': 2, 'name': u'Aanduiding van het chassisnummer '},
          {'key': u'3', 'id': 1, 'name': u'Typeplaatje'},
          {'key': u'4', 'id': 5, 'name': u'COC of gelijkvormigheidsattest '},        
          {'key': u'5', 'id': 4, 'name': u'Inschrijvingsbewijs '},
  
        ], 'id': 2, 'key': u'B', 'name': u'Onderdelen'},
        {'items': [
          {'key': u'6', 'id': 15, 'name': u'Batterij'},
          {'key': u'7', 'id': 11, 'name': u'Differentieel '},
          {'key': u'8', 'id': 13, 'name': u'Uitlaat '},
          {'key': u'9', 'id': 12, 'name': u'Cardanhoezen '},
          {'key': u'10', 'id': 10, 'name': u'Koppeling'}        
          ], 'id': 2, 'key': u'B', 'name': u'Onderdelen'}
      ]
  </code></pre>
  
  <p>I've tried as follows:</p>
  
  <pre><code>res = []
  for item in data:
    new_data = {
      'id': item['id'],
      'key': item['key'],
      'name': item['name'],
      'items': sorted(item['items'], key=lambda k : k['key']) 
    }
    res.append(new_data)
  
  print(res)
  </code></pre>
  
  <p>The first is sorted fine, but the second one not.</p>
  
  <p>What am I doing wrong and is there a better way of doing it?</p>