{
"JsonResult": {
"List": [{
"Subject": "Something",
"Type": 0,
"TypeDescription": "Referral"
}],
}
}
This is my sample json response i get while hitting my service, after that i have a button which carries option like Subject, Type and TypeDescription.
How can i sort the Json Response based on the parameter i send.
function sortItems(jsonResponse,paramater){
var sorted = jsonResponse.List.sort( function(a, b) {
var nameA = a.paramater.toLowerCase(),
nameB = b.paramater.toLowerCase();
return nameA.localeCompare(nameB);
}
Here is the sort function i am using, but its not working. I already have my JSON response and i need to sort at runtime based on the argument i send.
Here is a Js Fiddle for you which would give you a deeper insight.
http://jsfiddle.net/spechackers/EdAWL/