.sort strange behavior

Cyril Auburtin cyril.auburtin at gmail.com
Sat Oct 21 12:57:09 UTC 2017


```js
[0,1,3,4,7,8,8,9,13,17,22,23,26].concat([16,19,21,22,25,32]).sort((a,b)=>a-b)
// [ 0, 1, 3, 4, 7, 8, 8, 9, 13, 16, 17, 19, 21, 22, 22, 23, 25, 26, 32 ]

[0,1,3,4,7,8,8,9,13,17,22,23,26].concat([16,19,21,22,25,32]).sort()
// [ 0, 1, 13, 16, 17, 19, 21, 22, 22, 23, 25, 26, 3, 32, 4, 7, 8, 8, 9 ]
```
In the second case, it produces a weirdly sorted array, on node 8, chrome
or firefox

What could explain this?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20171021/7fd7a894/attachment.html>


More information about the es-discuss mailing list