data=(32 2 43 12 45 3 123 10)
sorted_data=($(for num in "${data[@]}"; do echo $num; done | sort -n))
# 输出排序后的数据
echo "${sorted_data[@]}"
#!/bin/bash
index=0
# 使用while循环和sort命令进行排序
sorted_data=($(while [ $index -lt ${#data[@]} ]; do
echo "${data[$index]}"
((index++))
done | sort -n))
echo "${sorted_data[@]}"