Skip to content

Instantly share code, notes, and snippets.

@gegagome
Last active October 2, 2019 16:14
Show Gist options
  • Save gegagome/454be095cb9c93f529eb92471f0e3d59 to your computer and use it in GitHub Desktop.
Save gegagome/454be095cb9c93f529eb92471f0e3d59 to your computer and use it in GitHub Desktop.
Sort in javascript
[[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