title: Python: insert new element into sorted list of dictionaries
body: <p>I've got a list of dictionaries that is already sorted by a key <code>id</code>.</p>
  
  <pre><code>y = [{'id': 0, 'name': 'Frank'},
       {'id': 5, 'name': 'Hank'},
       {'id': 8, 'name': 'Fred'},
       {'id': 30, 'name': 'Jill'}]
  </code></pre>
  
  <p>I want to insert a new element into the list.</p>
  
  <pre><code>y.append({'id': 6, 'name': 'Jenkins'})
  </code></pre>
  
  <p>How do I avoid sorting the list again as follows once the new element is added?</p>
  
  <pre><code>y = sorted(y, key=lambda x: x['id'])
  </code></pre>
  
  <p>The ideal outcome is:</p>
  
  <pre><code>y = [{'id': 0, 'name': 'Frank'},
       {'id': 5, 'name': 'Hank'},
       {'id': 6, 'name': 'Jenkins'},
       {'id': 8, 'name': 'Fred'},
       {'id': 30, 'name': 'Jill'}]
  </code></pre>
  
  <p>Edit:</p>
  
  <p>Using <code>bisect.insort(y, {'id': 6, 'name': 'Jenkins'})</code> will work only for the first key, if the dict is sorted by name, it will fail.</p>