the purpose of the code is to merge nums2 into nums1 as one sorted array. the first approach doesn't work as expected, the second one works fine, any explanation?
class Solution:
def merge(self, nums1: List[int], m: int, nums2: List[int], n: int) -> None:
nums1 = sorted(nums1[:m]+nums2[:n])
class Solution:
def merge(self, nums1: List[int], m: int, nums2: List[int], n: int) -> None:
nums1[m:]=nums2
nums1.sort()