title: Sort objects in an array alphabetically on one property of the array
body: <p>Let's say you have a JavaScript class like this</p>
  
  <pre><code>var DepartmentFactory = function(data) {
      this.id = data.Id;
      this.name = data.DepartmentName;
      this.active = data.Active;
  }
  </code></pre>
  
  <p>Let's say you then create a number of instances of that class and store them in an array</p>
  
  <pre><code>var objArray = [];
  objArray.push(DepartmentFactory({Id: 1, DepartmentName: 'Marketing', Active: true}));
  objArray.push(DepartmentFactory({Id: 2, DepartmentName: 'Sales', Active: true}));
  objArray.push(DepartmentFactory({Id: 3, DepartmentName: 'Development', Active: true}));
  objArray.push(DepartmentFactory({Id: 4, DepartmentName: 'Accounting', Active: true}));
  </code></pre>
  
  <p>So I now would have an array of objects created by <code>DepartmentFactory</code>. How would I go about using the <code>array.sort()</code> method to sort this array of objects by the <code>DepartmentName</code> property of each object?</p>
  
  <p>The <code>array.sort()</code> method works just fine when sorting an array of strings</p>
  
  <pre><code>var myarray=["Bob", "Bully", "Amy"];
  myarray.sort(); //Array now becomes ["Amy", "Bob", "Bully"]
  </code></pre>
  
  <p>But how do I make it work with a list of objects?</p>