title: Sorting list based on values from another list
body: <p>I have a list of strings like this:</p>
  
  <pre><code>X = ["a", "b", "c", "d", "e", "f", "g", "h", "i"]
  Y = [ 0,   1,   1,   0,   1,   2,   2,   0,   1 ]
  </code></pre>
  
  <p>What is the shortest way of sorting X using values from Y to get the following output?</p>
  
  <pre><code>["a", "d", "h", "b", "c", "e", "i", "f", "g"]
  </code></pre>
  
  <p>The order of the elements having the same "key" does not matter. I can resort to the use of <code>for</code> constructs but I am curious if there is a shorter way. Any suggestions?</p>