title: Sorting a Swift array by ordering from another array
body: <p>Say I have an array of the custom class <code>[Player]</code>, each of which contains a string property called <code>player.position</code></p>
  
  <p>I also have an arbitrary array of values, called <code>positionOrders</code>, like so:</p>
  
  <p><code>let positionOrders = ["QB", "WR", "RB", "TE"]</code></p>
  
  <p>Where my goal is to sort the <code>[Player]</code> to have all the "QB"s first, then "WR"s, "RB"s, and finally "TE"s.</p>
  
  <p>The current way I am doing loops through each element in <code>positionOrders</code>, then inside that loops through all the players to append to a new array. However, I could not figure a simpler (and more efficient) way to do this. Any tips or pointers are much appreciated. Thanks.</p>