bubble sort by pooq

3 :0".;._2(1!:1)3
n=.}.y
c=.s=.0
for_i.i.<:b=.{.y do.for_j.i.<:b-i do.t=.n{~j+1
if.t<j{n do.s=.>:s
n=.(t,j{n)(j,j+1)}n
end.
wd'compare =',(3":c=.>:c),'   swap =',(3":s),'   data:',3":n
end.end.
)

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

download

return to the top page