bubble sort by tails (ySas)

map{@@[@i]=sort{$a>$b&&++$-}@@[@i=$_-1..$_];printf"compare =%3d   swap =%3d   data:"."%3d"x@@.$/,++$c,$-,@@}1..--$@for($@,@@)=<>

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

download

return to the top page