for(<>){$o=$_;@_=();s%.%s/(.)(.*)/\2\1/;push@_,$_%eg;@_=sort@_;"@_"=~$o;print$`=~y/ //,' ',(join$/,@_)=~/.$/mg,$/}
Note that non-ascii characters in the above source code will be escaped (such as \x9f).
download
return to the top page