alphacyberranger@lemmy.world to Programmer Humor@programming.devEnglish · 1 year agoPick a side Javascriptlemmy.worldimagemessage-square13fedilinkarrow-up177arrow-down14
arrow-up173arrow-down1imagePick a side Javascriptlemmy.worldalphacyberranger@lemmy.world to Programmer Humor@programming.devEnglish · 1 year agomessage-square13fedilink
minus-squareKonlanx@feddit.delinkfedilinkarrow-up48·edit-21 year 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]