title: Given two lists in python one with strings and one with objects, how do you map them?
body: <p>I have a list of strings</p>
  
  <pre><code>string_list = ["key_val_1", "key_val_2", "key_val_3", "key_val_4", ...]
  </code></pre>
  
  <p>and a list with objects</p>
  
  <pre><code>object_list = [object_1, object_2, object_3,...]
  </code></pre>
  
  <p>Every object <code>object_i</code> has an attribute <code>key</code>.</p>
  
  <p>I want to <strong>sort the objects in <code>object_list</code> by the order of <code>string_list</code></strong>.</p>
  
  <p>I could do something like</p>
  
  <pre><code>new_list = []
  for key in string_list:    
      for object in object_list:
          if object.key == key:
              new_list.append(object)
  </code></pre>
  
  <p>but there must be a more pythonic way, then this brute force one. :-) How would you solve this?</p>