I need help sorting an array of objects as shown below.
var obj = [{"UMAIR":410},
{"ALI":2177},
{"JOHN":410},
{"ANTHENY":410},
{"FRANKLY":410},
{"FRONTY":534},
{"SLIM":534},
{"ASFUND":534}];
I want to sort the objects based on their integer values. I came across the following code online and I'm trying to understand how it works:
obj.sort(function(a, b) {
return a.price - b.price;
});
The code snippet above is using the price property to sort the objects, however, in my case I don't have a specific property like that.