Actually this is working fine.
After the indentation you can freely mix tabs and spaces. But doc strings are expected to maintain the same level of indentation as where they started. This is where Cobra is complaining about the mixing of tabs and spaces. For now anyway, I'm leaving this.
A few comments on the code:
-- You can use a "post while <condition>" loop if you like. This is like the "do ... while <condition>" in pseudo-code.
-- You might wish to put "shared" after "class Sorter" and indent the methods by one level since Sorter is not maintaining any state.
-- Since all the expectations of the sort method results are the same, you can move that out to a test method that takes the sort method as an argument. I've tested that this code works:
class Sorter
sig SortMethod(list as IList) as dynamic
shared
def testSort(sortMethod as SortMethod)
assert sortMethod([1,2,3,4])==[1,2,3,4]
assert sortMethod([3,4,1,2])==[1,2,3,4]
assert sortMethod([4,3,2,1])==[1,2,3,4]
assert sortMethod(['c','d','b','a'])==['a','b','c','d']
assert sortMethod([1,1,1,1])==[1,1,1,1]
def bubblesort(list as IList) as dynamic
test
.testSort(ref .bubblesort)
body
swapped=true
while swapped
swapped=false
for i = 0 .. list.count - 1
if list[i] to dynamic > list[i+1] to dynamic
.swap(list, i, i+1)
swapped=true
return list
def swap(list, a as int, b as int)
tmp = list[b]
list[b]=list[a]
list[a]=tmp
def main is shared
pass
-- It might be interesting to generate a really large list and run each of the algorithms, testing them for speed. But I would save that for a "phase 2" and just get the current stuff working.
HTH,
-Chuck