0

Sorting JavaScript Object by property value

JavaScript
var list = {
  "you": 100, 
  "me": 75, 
  "foo": 116, 
  "bar": 15
};

var sortable = [];
for (var item in list) {
    sortable.push([item, list[item]]);
}

sortable.sort(function(a, b) {
    return a[1] - b[1];
});

console.log(list); // {   bar: 15,  foo: 116,  me: 75,  you: 100 }
RUN
add comment
Suggest a different solution or add another example