[Solved] Javascript object sorting [closed]


You can’t sort properties in an object. Copy the data into an array and sort it.

Example:

var arr = [];
$.each(data, function(key, value){
  arr.push({ id: key, data: value });
});
arr.sort(function(x,y){
  var xn = x.data.userStatuINT;
  var yn = y.data.userStatuINT;
  return xn == yn ? 0 : xn < yn ? -1 : 1;
});

6

solved Javascript object sorting [closed]