I want to have a copy of my list, and then sort it, but due of the way that python works, if i sort the copy of the list, it sort also the original list. Here is my code:
def swapBySoting(arr):
newArr = arr
newArr.sort()
swap = 0
for i in range(len(arr)):
if arr[i] != newArr[i]:
swap +=1
return int(swap / 2)
I only need to know how to store the copy in another reference of memory, to sort only the copy. Thanks