SCRIPT TO BOUBLE SORT IN ARRAY

SCRIPT TO BOUBLE SORT IN ARRAY

#!/bash/sh
i=1
k=1
echo " enter array size "
read n
echo "enter array element"
while [ $i -le $n ]
do
read num

x[$k]=`expr $num`
i=`expr $i + 1`
k=`expr $k + 1`
done
x[$k]=0
k=1
while [ $k -le $n ]
do
j=1
while [ $j -lt $n ]
do
y=`expr $j + 1`
if [ ${x[$j]} -gt ${x[$y]} ]
then
t=`expr ${x[$j]}`
x[$j]=`expr ${x[$y]}`
x[$y]=`expr $t`
fi
j=`expr $j + 1`
done
k=`expr $k + 1`
done

k=1
echo "stored array is "
while [ ${x[$k]} -ne 0 ]
do
echo "${x[$k]}"
k=`expr $k + 1`
done