Result

AC

Code [DL]

a=()
while read -n 1 c;do
a+=($c)
done
q(){
local k i s=() l=()
p=()
(($#==0))&&return 0
k=$1
shift
for i;do
if [[ $i < $k ]];then
s+=("$i")
else
l+=("$i")
fi
done
q "${s[@]}"
s=("${p[@]}")
q "${l[@]}"
l=("${p[@]}")
p=("${s[@]}" "$k" "${l[@]}")
}
q "${a[@]}"
echo $(IFS=;echo "${p[*]}")

stdin

1831478666012396515526993882299083160977906471385460198306364893911552226881525080453599024834292497

stdout

0000000001111111111222222222223333333333444444445555555555666666666667777788888888888899999999999999

stderr

/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)

strace