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[@]}"
b=$(IFS=;echo "${p[*]}")
echo $b

stdin

6287953601770736677345463845350242041941624006183483468129869104705164710157662512209215190761220402

stdout

0000000000000111111111111122222222222233333334444444444445555555566666666666667777777777888888999999

stderr

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

strace