function getSortedKeys(obj) { var keys = Object.keys(obj); return keys.sort(function(a,b){return obj[b]-obj[a]}); }