Ugly implementation of mergesort
Neater merge function using pattern matching on tuple