Default sorting in JavaScript

I was wondering about the default sorting technique used in Array’s sort() method and turns out it is Insertion Sort.

More important is to understand how easy it is to answer these trivial questions using Chrome developer tools.

Try following in console:

var foo = [1, 2, 3, 4, 5, 6];

foo.sort(function (l,r) {
  console.log(foo, l , r);
  return r < l;
});

foo.sort(function (l,r) {
  console.log(foo, l , r);
  return r > l;
});

###Output:

[1, 2, 3, 4, 5, 6] 1 2
[1, 2, 3, 4, 5, 6] 2 3
[1, 2, 3, 4, 5, 6] 3 4
[1, 2, 3, 4, 5, 6] 4 5
[1, 2, 3, 4, 5, 6] 5 6
[1, 2, 3, 4, 5, 6] 1 2
[2, 1, 3, 4, 5, 6] 1 3
[2, 1, 1, 4, 5, 6] 2 3
[3, 2, 1, 4, 5, 6] 1 4
[3, 2, 1, 1, 5, 6] 2 4
[3, 2, 2, 1, 5, 6] 3 4
[4, 3, 2, 1, 5, 6] 1 5
[4, 3, 2, 1, 1, 6] 2 5
[4, 3, 2, 2, 1, 6] 3 5
[4, 3, 3, 2, 1, 6] 4 5
[5, 4, 3, 2, 1, 6] 1 6
[5, 4, 3, 2, 1, 1] 2 6
[5, 4, 3, 2, 2, 1] 3 6
[5, 4, 3, 3, 2, 1] 4 6
[5, 4, 4, 3, 2, 1] 5 6

Trivial but interesting