title: Replace json array with another, but keep the order
body: <p>I have an API that responds with json like this:</p>
  <pre><code>{'items':[
  {'id': 1, 'quantity': 3},
  {'id': 4, 'quantity': 7},
  {'id': 5, 'quantity': 1}
  ]}
  </code></pre>
  <p>I've made it so on page it fetches this API every 15 seconds, however there's a problem that every time it has a different order in array (if in example item with id=1 is on first place, it may be on last next time). Because of that blocks on page change their order too. I've tried to counter it like this:</p>
  <pre><code>   for (var i in response.items) {
                     let current_item = response.items[i];
                     for (var i2 in original_items.items) {
                         if (original_items.items[i2].id === current_item.id) {
                             original_items.items[i2] = current_item;
                         }
                     }
                 }
  </code></pre>
  <p>But it doesn't work this way. Sorting them by id is not a viable option aswell</p>