merge the sorted list