We can sort elements of list with swapping the numbers every time till the number is in its best place.
In terms of Time and Space complexity it would be the good solution, As we are using same list to sort and not iterating the numbers which are already sorted by the previous iteration.
nums = [0,2,1,2,0,2,0,1]
for ind_i, i in enumerate(nums):
for ind_j, j in enumerate(nums[ind_i+1:]):
if nums[ind_i]> nums[ind_i+ind_j+1]:
nums[ind_i], nums[ind_i+ind_j+1] = nums[ind_i+ind_j+1], nums[ind_i]