@x=<>;print sort{$x{$a}cmp$x{$b}}map{($x{$_}=lc)=~s/\d+/0 x(length("@x")-length$&).$&/ge;$_}@x