I'm using the Javascript sorting to sort an array of objects. This is why i'm trying to do (take the 10 best players in my array) :
this.topPlayers .sort(function(a, b) {
return a.stars > b.stars;
});
this.topPlayers = this.topPlayers.slice(0,10);
It returns me the same thing when i'm doing this (the 10 worst players) :
this.topPlayers .sort(function(a, b) {
return a.stars < b.stars;
});
this.topPlayers = this.topPlayers.slice(0,10);
What am I doing wrong ? Same results in both case, tried to sort on other properties, again same result... I'm using angular and doing it on ngOnInit() function.