[jQuery] Sorting a JSON object based on it's keys
I have a JSON object (dynamically created) which is given below:
var jsonObj = {
1 : {
"Name" : "B",
"Position" : "Sr"
},
2 : {
"Name" : "S",
"Position" : "Sr"
},
3 : {
"Name" : "A",
"Position" : "Jr"
}
};
In the above JSON object, keys can be strings also.
Is there anyway that I can sort this JSON object based on these keys?
The output should be as below:
var jsonObj = {
2 : {
"Name" : "Sai",
"Position" : "Sr"
},
1 : {
"Name" : "Bhushan",
"Position" : "Sr"
},
3 : {
"Name" : "Arun",
"Position" : "Jr"
}
};