title: Custom Sort List Using a Reference Order
body: <p>I would like to sort an array by the value in its first index, 0, of each row.The array has the following form:</p>
  
  <pre><code>['AAA', 1, 2, -1]
  ['BB+', 3, 2, 1]
  ['AA-', 5, 4, 1]
  ['AA+', 4, 2, 2]
  </code></pre>
  
  <p>As you can probably see, I would like to sort by some credit ratings. Unfortunately, simply sorting using built in functions doesn't provide the correct order. What I'd like to do is to somehow specify the order, for example:</p>
  
  <pre><code>correct_order = ['AAA', 'AA+',...,'BBB+', 'BBB', 'BB+',...]
  </code></pre>
  
  <p>I can imagine there are countless ways to accomplish this, possibly without specifying it. I'm not worried about performance since I will never be working with more than 22 rows. </p>
  
  <p>One important point to emphasize is that the sorting will be based on Index 0 in each row, but preserving the rest of the array. Also, there is no guarantee that the array will contain every "Rating" in the correct_order list. </p>
  
  <p>I have seen similar problems explained on the forum, but haven't been able to adapt them to my data set. Any help with the simplest solution would be greatly appreciated.</p>