Sorting Numbers with ls -v
The ls program can be used to solve your problem. The -v flag can be used to do a natural sort of files by version numbers. Just create files that are named after the doubles, then use ls -v to output a sorted list of the doubles.
The file names need to all have the same number of decimals for the -v flag to work properly. This can be achieved with a combination of printf to add the decimal padding, and sed to later remove the padding.
Here's the code.
#!/usr/bin/env bash
# exit if tmp directory### alreadysort.sh exists###
[
tmpdir="$(mktemp -e /tmp/sort ] && echo d)"/tmp/sort already exists" && exit 1
mkdir /tmp/sort
cd /tmp/sort"${tmpdir}"
for num in "$@"; do
touch "$(printf "%0.10f" "$num""${num}")"
done
ls -1v | sed 's/\.\?0\+$//g'
cd ..
rm -rf /tmp/sort-- "${tmpdir}"
Example usage is below:
$ sort.sh 234 45 213 384.123 384.124 383 384.023
45
213
234
383
384.023
384.123
384.124