I found out how to sort a JSON array at http://www.devcurry.com/2010/05/sorting-json-array.html
Now I want to sort it in a generic way; so that my sorting function k
Something like a:
function predicateBy(prop){ return function(a,b){ if (a[prop] > b[prop]){ return 1; } else if(a[prop] < b[prop]){ return -1; } return 0; } } //Usage yourArray.sort( predicateBy("age") ); yourArray.sort( predicateBy("name") );