title: Javascript: custom array sorting or sorting based on a pattern
body: <p>I have an idea on how to improve some code but that would require using arrays and these arrays have to have a certain sorting order.</p>
  
  <p>I have a given array: <code>var p = ['skewX', 'translateY', 'scale', 'rotateX'];</code>.</p>
  
  <p>I need these strings sorted inside the array on a pattern:</p>
  
  <p><code>0 translate</code>, <code>1 rotate</code>, <code>2 skew</code>, <code>3 scale</code></p>
  
  <p>or</p>
  
  <p><code>0 ordered translations</code>, <code>1 ordered rotations</code>, <code>2 ordered skews</code>, <code>3 ordered scales</code></p>
  
  <p>where</p>
  
  <p><code>index</code> and <code>string</code></p>
  
  <p>Question: is it possible to sort these arrays based on this pattern?</p>
  
  <p>Thanks so much.</p>