Merge sort written in Javascript