Result

AC

Code [DL]

a={case[x],s->x
case[x,*y],s->x+s+a(y,s)}
f={n->{x->a(split(x,n)," "+n+" ")}}
stdin|f("0")|f("1")|f("2")|f("3")|f("4")|f("5")|f("6")|f("7")|f("8")|{x->a(sort(split(x)),"")}|puts

stdin

9693816387465339947808715871130172170562487571075214547985855726711544718808779828973176714817103859

stdout

0000001111111111111112222233333334444444455555555555666666777777777777777777788888888888888899999999

stderr

strace