You are on page 1of 1

declare -a list=()

for((i=0;i<9;i++))
do
echo "Digite un numero"
read num1;
list[$i]=$num1;
done

function order_list()
{
(($# > 0)) && list=("$@")
local j=0 ubound=$((${#list[*]} - 1))
while ((ubound > 0))
do
local i=0
while ((i < ubound))
do
if [ "${list[$i]}" \> "${list[$((i + 1))]}" ]
then
local t="${list[$i]}"
list[$i]="${list[$((i + 1))]}"
list[$((i + 1))]="$t"
fi
((++i))
done
((++j))
((--ubound))

done
echo $j
}

order_list ${list[@]}
echo ${list[@]}
exit 0

You might also like