Hacker News new | ask | show | jobs
by jwilk 2832 days ago
a > b is not a consistent comparison function. The behavior of sort() with such a function is implementation-defined.
1 comments

Agreed. I wouldn't use it the way shown here. I would make sure to return a hard negative, zero, or one in any case.

I was surprised when I read into how many different ways `Array.prototype.sort()` is implemented across environments.