Swapping the values from 1st position to till the end of the list, this code loops for ( n*n-1)/2 times. Each time it pushes the greater value to the greater index starting from Zero index.
list2 = [40,-5,10,2,0,-4,-10]
for l in range(len(list2)):
for k in range(l+1,len(list2)):
if list2[k] < list2[l]:
list2[k] , list2[l] = list2[l], list2[k]
print(list2)