title: sort object properties and JSON.stringify
body: <p>My application has a large array of objects, which I stringify and save them to the disk. Unfortunately,  when the objects in the array are manipulated, and sometimes replaced, the properties on the objects are listed in different orders (their creation order?). When I do JSON.stringify() on the array and save it, a diff shows the properties getting listed in different orders, which is annoying when trying to merge the data further with diff and merging tools.</p>
  
  <p>Ideally I would like to sort the properties of the objects in alphabetical order prior to performing the stringify, or as part of the stringify operation. There is code for manipulating the array objects in many places, and altering these to always create properties in an explicit order would be difficult. </p>
  
  <p>Suggestions would be most welcome!</p>
  
  <p>A condensed example:</p>
  
  <pre><code>obj = {}; obj.name="X"; obj.os="linux";
  JSON.stringify(obj);
  obj = {}; obj.os="linux"; obj.name="X";
  JSON.stringify(obj);
  </code></pre>
  
  <p>The output of these two stringify calls are different, and showing up in a diff of my data, but my application doesn't care about the ordering of properties. The objects are constructed in many ways and places.</p>