merge sorted array rather than linked list