4 ms·
a > b is not a consistent comparison function. The behavior of sort() with such a function is implementation-defined.
by jwilk 8y ago
a > b is not a consistent comparison function. The behavior of sort() with such a function is implementation-defined.
- 52-6F-62 8y agoAgreed. 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.