Mergesort implementation using only arrays