title: How to arrange array of object with specific order
body: <p>I have an array of objects, each object has a "condition" property. It can either be a single value string ex <code>"Original"</code>, or a multiple comma separated values string ex <code>"Original, Brand new"</code>.  <a href="https://stackoverflow.com/questions/5002848/how-to-define-custom-sort-function-in-javascript">i see this question also</a> , but in that not tell about sort for given order</p>
  
  <pre><code>[
    {id: 1, condition: "Original"},
    {id: 2, condition: "Original, Used"},
    {id: 3, condition: "Used"},
    {id: 4, condition: "After market"},
    {id: 5, condition: "After Market,Used"},
    {id: 6, condition: "Used"},
    {id: 7, condition: "Used, Original"},
  ]
  </code></pre>
  
  <p>I want to sort my array based on the "condition" property and the sort function should accept an argument being an array of keys to ask for a specific order:</p>
  
  <p>Given the following keys as input <code>["Original","Used","After Market"]</code>,
  the sort function would return this array:</p>
  
  <pre><code>[
    {id: 1, condition: "Original"},
    {id: 2, condition: "Original, Used"},
    {id: 7, condition: "Used, Original"}
    {id: 3, condition: "Used"},
    {id: 6, condition: "Used"},
    {id: 5, condition: "After Market,Used"},
    {id: 4, condition: "After market"},
  ]
  </code></pre>