Python sort

i have written a code to get the following result but i think am missing something

def insert_switch(list):
    for i in range(len(list)-1,0) :
value =list       
        for j in range(i,len(list)) :
            if (list[j-1]>list[j]) :
                value=list[j]
                list[j]=list[j-1]
                list[j-1]=value
                j=j+1
                i=i-1
else :
break

Expected result
basically sorting from right

[8 ,11 ,4 ,33][]
[8, 11, 4 ][33]
[8 ,11 ][4,33]
[8][4,11,33]
[][4,8,11,33]

I wrote in python but there is something wrong i did

Is there any perl or python code that would help?

This for i in range(len(list)-1,0) : isn't doing anything as you len(list)-1 is already greater than 0 try using a -1 increment like this:

    for i in range(len(list)-1,0,-1) :

Also, have you considered using list.sort()