alphacyberranger to Programmer [email protected] • 10 months agoI'll just sort it myselfimagemessage-square48arrow-up1936arrow-down112
arrow-up1924arrow-down1imageI'll just sort it myselfalphacyberranger to Programmer [email protected] • 10 months agomessage-square48
minus-square@[email protected]linkfedilink3•10 months 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•10 months 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