I want to sort an array objects like so.
var obj = [{"UMAIR":410},
{"ALI":2177},
{"JOHN":410},
{"ANTHENY":410},
{"FRANKLY":410},
{"FRONTY":534},
{"SLIM":534},
{"ASFUND":534}];
I want to sort it with integer values of each object. I am trying to understand following code (that I have found online):
obj.sort(function(a, b) {
return a.price - b.price;
});
But in this code its using price property, but I dont' have any specific property here.
[["JOHN", 123], ..](eg. the 2nd component is always the value) or an object structure with fixed keys as in[{name: "JOHN", price: 123}, ..].