I am attempting to organize an array based on the win and lose ratio of each player.
This is how my code currently looks:
const array = [{playerName: 'toto', win: 2, lose: 2}, {playerName: 'titi', win: 0, lose: 0}, {playerName: 'tata', win: 3, lose: 1}];
array.sort((a, b) => a.win / a.lose || b.win / b.lose);
console.log(array);
The positioning of player 'titi' above player 'toto' in the sorted array is confusing me.