Fast merge sort in JavaScript
[...] it misbehaves in some subtle or pathological cases.


I may have identified a pathological case...

Caveat When Using Bitwise Shifting

This pertains to the following line:

var begin_right = begin + (size &gt;&gt; 1);


Using bitwise shifting to efficiently multiply or divide by a factor of two carries a risk when extremely large numbers are involved. size &gt;&gt; 1 will stop behaving predictably when size exceeds 2147483647. 

This is fine if you don't expect to be sorting arrays of such magnitude, but you might as well double that range by using an unsigned bitwise shift (&gt;&gt;&gt;), allowing you to shift any positive number up to 4294967295.

If you want to be safe with arrays even longer than that, you can use Math.floor(size/2) although that will negatively impact performance.

Here's a fiddle to demonstrate: http://jsfiddle.net/akxbLej5/1/