alphacyberranger@lemmy.world to Programmer Humor@programming.devEnglish · 2 years agoPick a side Javascriptlemmy.worldimagemessage-square11linkfedilinkarrow-up134arrow-down14
arrow-up130arrow-down1imagePick a side Javascriptlemmy.worldalphacyberranger@lemmy.world to Programmer Humor@programming.devEnglish · 2 years agomessage-square11linkfedilink
minus-squareKonlanx@feddit.delinkfedilinkarrow-up48·edit-22 years agoIt’s not. The default sorter does that, because that way it can sort pretty much anything without breaking at runtime. You can overwrite it easily, though. For the example above you could simply do it like this: [3, 1, 10].sort((a, b) => a - b) Returns: [1, 3, 10]
It’s not. The default sorter does that, because that way it can sort pretty much anything without breaking at runtime. You can overwrite it easily, though. For the example above you could simply do it like this:
[3, 1, 10].sort((a, b) => a - b)
Returns:
[1, 3, 10]