title: How to sort a JS object of objects?
body: <p>I have built an object in PHP, used JSON_encode function and send it as a JSON string to my JS script via ajax.  Then I convert it back to an object.  The problem I am having is that I wanted to keep the object in the order that it was originally created in.  Please see this picture of what the object looks like once I get it into JS:</p>
  
  <p><img src="https://i.stack.imgur.com/Bj4tB.png" alt="enter image description here"></p>
  
  <p>When I created the object, it was sorted by the customer field alphabetically.  The customer name starting with A would come first, B second, etc.  As you can see, now, the first element of the object as customer starting with S.  It looks like somehow it got automatically sorted by the key of the top-level object, which is an integer, so I understand why this happened. </p>
  
  <p>So i want to do is re-sort this object so that all the sub-objects are sorted by the <code>customer</code> field alphabetically.  Is this possible?  If so, how do I do it?</p>
  
  <p>Thanks!</p>