title: How to keep an Javascript object/array ordered while also maintaining key lookups?
body: <p>I have some data which I originally stored in a generic Javascript object, with the ID as a key:</p>
  
  <pre><code>{
    "7": {"id":"7","name":"Hello"},
    "3": {"id":"3","name":"World"},
    ...
  }
  </code></pre>
  
  <p>However, I discovered that browsers do not guarantee a particular object order when looping through them, so in the above "3" would come before "7". I switched to using an array format like this:</p>
  
  <pre><code>[
    {"id":"7","name":"Hello"},
    {"id":"3","name":"World"},
    ...
  ]
  </code></pre>
  
  <p>Now, I can loop in the correct order but cannot do fast lookups, e.g. <code>data["3"]</code> without having to loop through the array.</p>
  
  <p>Is there a good way to combine both approaches? I would rather avoid using a separate object for each format, because the object is pretty large (hundreds of elements).</p>