I see nothing wrong with your code, and it runs fine for me. What line is it crashing on?

I would note that the "mergesort" function is a bit misnamed ... it's more of a merge.