bubble sort by Fleur

RS--{for(n=NF;NF*=j%n||n-=i=1;){j=i;s+=$j>(t=$++i)&&($i=$j)>$j=t;sub(/^. | . /," &");printf"compare =%3d   swap =%3d   data: "$0ORS,++c,s}}

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

download

return to the top page