
July 7th, 2012, 09:16 PM
|
|
Registered User
|
|
Join Date: Jul 2012
Posts: 1
Time spent in forums: 14 m 48 sec
Reputation Power: 0
|
|
|
Implementing a BubbleSort
I'm attempting to implement a bubble sort in python with the following code but it is not working properly. My thoughts are that the for loop is not restarting. Can someone point out my error. Thanks
Code:
def bubbleSort(a):
for i in range(len(a)):
if ((i < (len(a) - 1)) and (a[i] > a[i+1])):
temp = a[i]
a[i] = a[i + 1]
a[i + 1] = temp
i = -1
|