News for hackers. Stuff that matters.
Re:The Curious Case of JavaScript’s `sort` by zeveb on Wednesday April 13, 2016 @12:27PM (#11489627)
> So if I'm understanding correctly, JS sort sorts numbers by their string value? That's crazy.

It's JavaScript … it doesn't have to be sane; we'll use it anyway.

I think that Erlang had the most elegant solution: it defines a total order over all objects (number < atom < reference < fun < port < pid < tuple < list < bit string). Of course, Erlang's 'strings' are pretty inelegant (they're just lists of integers, which are printed as strings if they happen to incidentally be valid characters), so I guess there's some Law of Conservation of Bogosity at play here.

There are no comments on this comment yet.