0: {id: 2575, groepName: "ezeez-1", groupScore: 50, Players: Array(0)}
1: {id: 2574, groepName: "ezeez-2", groupScore: 25, Players: Array(0)}
2: {id: 2576, groepName: "ezeez-3", groupScore: 10, Players: Array(0)}
3: {id: 2577, groepName: "ezeez-4", groupScore: 100, Players: Array(0)}
I need help sorting this array based on the group score. I've looked at other StackOverflow questions but didn't find a clear solution that works for me. Can anyone provide some guidance?
sortGroups(){
var i = 0;
var i2 = 1;
if (this.lobbygroups[i].groupScore < this.lobbygroups[i2].groupScore){
return -1;
}
if (this.lobbygroups[i].groupScore > this.lobbygroups[i2].groupScore){
return 1;
}
i++;
i2++;
return 0;
}
}
this.lobbygroepen.sort(sortGroups);