I have this object array
var grps = [{
group_no: 0,
id: "733",
xpos: 226.72,
ypos: 100
}, {
group_no: 0,
id: "735",
xpos: -1.19,
ypos: 200
}];
and im trying to sort the array based on value xpos
var small_x = grps.sort(function(a, b) {
return a.xpos - b.xpos;
});
and when i do
console.log(small_x[0].xpos); //sort asc
I expect the value to be -1.19
but iam getting 226.72