Write a function to implement a specific algorithm (e.g., sorting, searching). Implement a stable merge sort that returns the input integers in ascending order without calling Python's built-in sorting functions. The function must return a new list and leave the input list unchanged. Input: a list of integers. Output: a new sorted list containing the same values.
Example: nums = [5, 2, 4, 1] produces [1, 2, 4, 5]. An empty list produces an empty list.
Constraints: 0 <= len(nums) <= 1,000, and each integer is between -10^9 and 10^9.
def merge_sort(nums):