bubble sort by nn

for(d=[n=-1];c=readline(S=' ');d[n++]=f(S+c))f=/..$/
for(s=i=0;(i%=n)||--n;print('compare =',f(S+ ++c),S,'swap =',f(S+s),S,'data:',d.join(S)))s+=v=(u=d[i])>(d[i]=d[++i]),d[i-!v]=u

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

download

return to the top page