bubble sort by murky-satyr

c:=s:=0
f:=method((.."")alignRight(3))
File standardInput readLines slice(1)map(f)do(map(i,_,for(j,0,size-i-2,at(j)<at(j+1)or swapIndices(j,j-s+s=s+1)
writeln("compare =",(c=c+1)f,"   swap =",s f,"   data:",join))))

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page