0

Its sorting only the half of list i have debugged but not getting to work.

mylist = [16, 19, 11, 15, 10, 12, 14]

for j in range(len(mylist)):   
    isSwapped = False
    i = 0
    while i<len(mylist)-1:      
        if mylist[i]>mylist[i + 1]:
            mylist[i], mylist[i + 1] = mylist[i + 1], mylist[i]          
            isSwapped = True
        else:
            isSwapped = False
        i = i+1
    if isSwapped == False:
        break
print (mylist)

Currrent output

[11, 15, 10, 12, 14, 16, 19]

wanted to complete list to be sorted any hint or suggestion will be very helpful.

pylist
  • 349
  • 3
  • 6

0 Answers0