funcmergeSort(nums []int)[]int{iflen(nums)<2{return nums
}
i :=len(nums)/2
left :=mergeSort(nums[:i])
right :=mergeSort(nums[i:])
result :=merge(left, right)return result
}funcmerge(left, right []int)[]int{
result :=[]int{}
i, j :=0,0
l, r :=len(left),len(right)for i < l && j < r {if left[i]> right[j]{
result =append(result, right[j])
j++}else{
result =append(result, left[i])
i++}}
result =append(result, left[i:]...)
result =append(result, right[j:]...)return result
}funcmain(){
arr :=[]int{8,9,5,7,1,2,5,7,6,3,5,4,8,1,8,5,3,5,8,4}
result :=mergeSort(arr)
fmt.Println(result)}