I'm just looking for constructive criticism of my Ruby implementation of a bubble sort algorithm.
class BubbleSorter < Object
def bubble_sort(list)
swaps = 0
# parse the list until it is sorted
until @sorted == true
# run the comparison of adjacent elements
for i in 0...(list.length - 1)
# if the first is greater than the second, swap them with parallel assignment
if list[i] > list[i+1]
list[i], list[i+1] = list[i+1], list[i]
# increase the number of swaps performed in this run by 1
swaps += 1
end
# compare the next 2 elements
i += 1
end
# uncomment the following line to see each iteration:
# p list
# If any swaps took place during the last run, the list is not yet sorted
if swaps > 0
@sorted = false
# no swaps? Everything is in order
else
@sorted = true
end
# reset swap count for each run
swaps = 0
end
end
end