Last active
October 2, 2019 16:14
-
-
Save gegagome/454be095cb9c93f529eb92471f0e3d59 to your computer and use it in GitHub Desktop.
Sort in javascript
This file contains hidden or 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
[[2, 37], [1, 40], [3, 39], [0, 36]].sort(([,a],[,b]) => { | |
count; | |
console.log(count + " a: " + a + ", b: " + b); | |
count++; | |
return a-b}) | |
/* | |
0 a: 40, b: 37 | |
1 a: 39, b: 40 | |
2 a: 39, b: 40 | |
3 a: 39, b: 37 | |
4 a: 36, b: 39 | |
5 a: 36, b: 37 | |
0: [0, 36] | |
1: [2, 37] | |
2: [3, 39] | |
3: [1, 40] | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment