Given two arrays of integers nums1 and nums2, both sorted in non-decreasing order, return a new array containing all elements from both arrays in non-decreasing order. The function should preserve duplicates and handle empty arrays correctly.
Example 1:
Input: nums1 = [1, 3, 5], nums2 = [2, 4, 6]
Output: [1, 2, 3, 4, 5, 6]
Explanation: Repeatedly take the smaller front element from the two arrays.
Example 2:
Input: nums1 = [1, 2, 2], nums2 = [2, 3]
Output: [1, 2, 2, 2, 3]
Explanation: Equal values are all kept in the merged result.
0 <= len(nums1), len(nums2) <= 10^5-10^9 <= nums1[i], nums2[i] <= 10^9nums1 and nums2 are each sorted in non-decreasing order