You are given an integer 51234 (say) we need to sort the digits of a number the output will be 12345.
51234
12345
How to do it without using array ?
You don't need to write a program at all, just do it with shell commands:
echo "51234" | sed 's+\(.\)+\1\n+g' | sort | tr -d '\n'