bubble sort by murky-satyr

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)))if((t=d[i])>d[++i])d[i-1]=d[i],d[i]=t,++s

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

download

return to the top page