- #1
- 49
- 0
This was written in python as an excersie, it's a terribly inefficient use of python. Still I don't understand why the sort doesn't stop as soon as possible
can anyone one point out the error?
can anyone one point out the error?
Code:
def bubbleSort (theList):
size = len(theList) - 1
while (size > 0):
index = 0
while (index < size):
if (theList[index] > theList[index+1]):
temp = theList[index]
theList[index] = theList[index+1]
theList[index+1] = temp
index = index + 1
size = size - 1
print theList