bubble sort by pooq

f=:3 :0
n=.}.a=.".;._2(1!:1)3
c=.s=.0
for_i.i.<:b=.{.a 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.
)
f''

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

download

return to the top page