title: Generic way of sorting JSON array by attribute
body: <p>I found out how to sort a JSON array at <a href="http://www.devcurry.com/2010/05/sorting-json-array.html" rel="noreferrer">http://www.devcurry.com/2010/05/sorting-json-array.html</a></p>
  
  <p>Now I want to sort it in a generic way; so that my sorting function knows which attribute to sort by. </p>
  
  <p>For example if my array is </p>
  
  <pre><code>[
    {
      "name": "John",
      "age": "16"
    },
    {
      "name": "Charles",
      "age": "26"
    }
  ]
  </code></pre>
  
  <p>I want to avoid writing different if cases to know if I should sort by name or age. I just want to pass a parameter 'name' or 'age' and my sorting function should know what to do.</p>
  
  <p>Thanks.</p>