Re:The Curious Case of JavaScript’s `sort`
by fenomas on Wednesday April 13, 2016 @11:27AM
(#11488989)
Certainly it's an easy mistake to make, but most JS devs tend to encounter it the very first time they call sort() on anything that isn't epoch dates. The fact that the author's code worked for years is a pretty exotic edge case!
Re:The Curious Case of JavaScript’s `sort`
by oldmanjay on Wednesday April 13, 2016 @11:27AM
(#11488983)
This behavior has been documented forever, and the broken code written in ignorance of this behavior passed into production because of inadequate testing. Nothing you've said countered these facts.
It is a very easy mistake to make, you pick 'sort' and the resulting code does what you expect. As long as all the timet's have the same number of digits then the string comparison works. You have to have a data that crosses 9/8/2001 to see the problem. (or 3/3/1973 before that)
The javascript compiler isn't going to tell you about this and it only hits a problem with dates older than most programs that are written in javascript.