News for hackers. Stuff that matters.
Re:The Curious Case of JavaScript’s `sort` by tzs on Wednesday April 13, 2016 @02:03PM (#11490622)
> JavaScript sorts arrays by using a default comparator that runs .toString and compares unicode code point values (with safe handling around null/undefined).

Is there an explanation somewhere of how they decided on that as the default comparator? My first inclination would have been to use "<" as the default comparator. That would sort purely numeric arrays numerically, and purely string arrays lexically, leaving only the case of arrays that mix numerical and non-numerical elements needing the programmer to step in and give an explicit comparator.

There are no comments on this comment yet.