when input is [3,2,1],the result given by my computer is [1,2,3],but the submit result is [3,2,1],i don't know why ,could someone help me?

```
i = len(nums)-1
index = 0
while i>0:
if nums[i]>nums[i-1]:
index = i
break
else:
i -= 1
if i == 0:
nums = sorted(nums)
else:
mi = min(i for i in nums[index:] if i>nums[index-1])
loc = nums[index:].index(mi)
nums[index-1],nums[index+loc] = nums[index+loc],nums[index-1]
nums[index:] = sorted(nums[index:])
```