Not Sure How To Sort This Json Object Jquery/javascript
Sample String: var output = { 'myservices':[ {'name':'oozie', 'hostidn': '1', 'details':'failed process health monitor....', 'currstatus':'Warning', 'currstatusclas
Solution 1:
function sortObjectsByKey(objects, key){
objects.sort(function() {
return function(a, b){
var objectIDA = a[key];
var objectIDB = b[key];
if (objectIDA === objectIDB) {
return 0;
}
return objectIDA > objectIDB ? 1 : -1;
};
}());
}
sortObjectsByKey(output.myservices, "hostidn");
console.log(output.myservices);
Post a Comment for "Not Sure How To Sort This Json Object Jquery/javascript"