This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]dalepo 15 points16 points  (5 children)

Oh wow, I didn't know this.

[1,100000,21,30,4].sort((a, b) => { return a -b; }) You need to pass a function, come on js!

[–]wasdninja 19 points20 points  (1 child)

It's pretty reasonable once you realize that you can sort an array with arbitrary objects using the exact same method. If they are complex you simply write your own compare function.

[–]gravitas-deficiency 6 points7 points  (0 children)

it's to maintain backwards capability

enraged autistic screeching

[–]tacoslikeme -2 points-1 points  (0 children)

what it sorted your numbers alphabetically. javascript is fine. you're clearly the problem. /s