Created
March 11, 2019 21:24
-
-
Save ctavan/e3efa8dc61c3759987ffad5fdc5cdd24 to your computer and use it in GitHub Desktop.
Array Sort Behavior Node 10 and 11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const unsorted1 = [1, 0, 0, 1]; | |
console.log(process.version, [...unsorted1], '->', unsorted1.sort(( value ) => value)); | |
const unsorted2 = [1, -1, -1, 1]; | |
console.log(process.version, [...unsorted2], '->', unsorted2.sort(( value ) => value)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
v8.15.1 [ 1, 0, 0, 1 ] -> [ 0, 0, 1, 1 ] | |
v10.15.2 [ 1, 0, 0, 1 ] -> [ 0, 0, 1, 1 ] | |
v11.9.0 [ 1, 0, 0, 1 ] -> [ 1, 0, 0, 1 ] // <----- OUCH! | |
v8.15.1 [ 1, -1, -1, 1 ] -> [ -1, -1, 1, 1 ] | |
v10.15.2 [ 1, -1, -1, 1 ] -> [ -1, -1, 1, 1 ] | |
v11.9.0 [ 1, -1, -1, 1 ] -> [ -1, -1, 1, 1 ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment