alphacyberranger@sh.itjust.works to Programmer Humor@programming.dev · 1 year agoI'll just sort it myselfsh.itjust.worksimagemessage-square48fedilinkarrow-up1930arrow-down112
arrow-up1918arrow-down1imageI'll just sort it myselfsh.itjust.worksalphacyberranger@sh.itjust.works to Programmer Humor@programming.dev · 1 year agomessage-square48fedilink
minus-squareArmand1@lemmy.worldlinkfedilinkarrow-up8arrow-down4·1 year 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-squareSpyingEnvy@lemm.eelinkfedilinkarrow-up2·1 year agoOne hundred percent how I do it everytime.
minus-squaresmik@discuss.tchncs.delinkfedilinkarrow-up5·1 year 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