DEV Community

loading...

Discussion on: Daily Challenge #26 - Ranking Position

Collapse
ceck profile image
Ceck

i want to contribute my idea with your code. i hope u enjoy with that. Maybe it's shoter


players.sort((a, b) => {
return (a.points == b.points ? a.name > b.name : a.points < b.points) || -1;
}).map((e,i)=>({...e,position:(i+1)}))

Forem Open with the Forem app