title: sorting json object based on attribute
body: <p>I have json object array containing firstname, lastname and age. I want to sort array based on age.</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;body&gt;
    &lt;h2&gt;Create Object from JSON String&lt;/h2&gt;
    &lt;p&gt;Original name: &lt;span id="origname"&gt;&lt;/span&gt;&lt;/p&gt;
    &lt;p&gt;New name: &lt;span id="newname"&gt;&lt;/span&gt;&lt;/p&gt;
    &lt;p&gt;Age: &lt;span id="age"&gt;&lt;/span&gt;&lt;/p&gt;
  
    &lt;script&gt;
      var employees = [
        { "firstName" : "John" , "lastName" : "Doe" , "age":"24" }, 
        { "firstName" : "Anna" , "lastName" : "Smith" , "age":"30" }, 
        { "firstName" : "Peter" , "lastName" : "Jones" , "age":"45" }, 
      ];
  
      document.getElementById("origname").innerHTML=employees[0].firstName + " " + employees[0].lastName;
  
      // Set new name
      employees[0].firstName="Gilbert";
      document.getElementById("newname").innerHTML=employees[0].firstName + " " + employees[0].lastName;
  
      document.getElementById("age").innerHTML=employees[0].age;
    &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>