I am currently working with an array of objects that looks like this:
[
{
'1485958472927784961': {
name: 'bruno fiverr',
points: 6,
user_id: '1485958472927784961',
tweets: [Array]
},
'1414575563323420679': {
name: 'ju',
points: 7,
user_id: '1414575563323420679',
tweets: [Array]
}
}
]
My goal is to sort this array based on the number of points each user has. I attempted to achieve this using the array.sort method along with a custom function:
var top10 = array.sort(function(a, b) { return a.points > b.points ? 1 : -1; }).slice(0, 10);
However, I keep getting the original array without any changes. Is it possible to accomplish what I'm trying to do?