alphacyberranger to Programmer [email protected] • 2 years agoI'll just sort it myselfsh.itjust.worksimagemessage-square48fedilinkarrow-up1928arrow-down112
arrow-up1916arrow-down1imageI'll just sort it myselfsh.itjust.worksalphacyberranger to Programmer [email protected] • 2 years agomessage-square48fedilink
minus-square@[email protected]linkfedilink4•2 years agoAs annoying as this is, you are meant to use a comparer. mapped.sort((a, b) => { if (a.value > b.value) { return 1; } if (a.value < b.value) { return -1; } return 0; });
minus-square@[email protected]linkfedilink5•2 years agoStuff like that exists to remind us of the Java in JavaScript
As annoying as this is, you are meant to use a comparer.
mapped.sort((a, b) => { if (a.value > b.value) { return 1; } if (a.value < b.value) { return -1; } return 0; });
arr.sort((a, b) => a - b);
One hundred percent how I do it everytime.
Stuff like that exists to remind us of the Java in JavaScript