I have this array of objects, I need to sort the 'list' by 'score' in descending order by score.
var list =[{ '440684023463804938': { score: 6, bonuscount: 2 },
'533932209300832266': { score: 20, bonuscount: 0 },
'448746017987231756': { score: 9, bonuscount: 0 },
'492585498561216513': { score: 14, bonuscount: 0 } }]
I usually do with .sort function, but this time it gives me list.sort is not a function
Any help is appreciated.
listis declared, it would definitely have a.sort()method. It doesn't much matter because there's only one item in the array, so it's already sorted.list[0].sort(...)well that won't work; there's no.sort()method on objects because you can't impose your own ordering on object property names.