title: Preserve insert order of object array after sort in Javascript
body: <p>I've got a array of objects like the following:</p>
  
  <pre><code>var a = {
   "TypeID" : 15,
   "Attr1" : "Something"
  };
  
  var b = {
   "TypeID" : 17,
   "Attr1" : "Something"
  };
  
  var c = {
   "TypeID" : 15,
   "Attr1" : "Something"
  };
  
  var d = {
   "TypeID" : 15,
   "Attr1" : "Something"
  };
  
  var e = {
   "TypeID" : 1,
   "Attr1" : "Something"
  };
  
  var objectArray = new Array();
  objectArray.push(a);
  objectArray.push(b);
  objectArray.push(c);
  objectArray.push(d); 
  </code></pre>
  
  <p>I tried to sort the array using the TypeID as the value for order, however I need to preserve the order insert. I meant, the final order must be the following:</p>
  
  <pre><code>e,a,c,d,b
  </code></pre>
  
  <p>But when I implement the classical sort algorithms(Bubble or Quicksort) I get the array ordered but the insert order of similiar value(TypeID) are in different possition.</p>
  
  <p>I tried to order at first time similar types of objects, but got lost with the rest.</p>