title: Sort the values in the array in the recurring order provided by another array?
body: <p>How to sort randomly placed values in one <code>array</code> so that it matches the <code>order</code> provided by another array, but instead of appending the duplicates one after the other, the function should append the group of values, provided by the <code>order</code> variable, one after the other.</p>
  
  <p><strong>Input:</strong></p>
  
  <pre><code>const array = [1, 5, 4, 3, 5, 3, 1, 5, 4];
  const order = [5, 1, 3, 4];
  </code></pre>
  
  <p><strong>Correct Output:</strong></p>
  
  <pre><code>const correctlyOrderedArray = [5, 1, 3, 4, 5, 1, 3, 4, 5];
  </code></pre>
  
  <p><strong>Wrong Output:</strong></p>
  
  <pre><code>const wronglyOrderedArray = [5, 5, 5, 1, 1, 3, 3, 4, 4];
  </code></pre>