title: Shell Bash script to print numbers in ascending order
body: <p>I am really new to shell Bash scripting.  I need to print numbers in ascending order on a line for a given arbitrary number that is input by the user.</p>
  
  <pre><code>#!/bin/bash
  
  declare nos[5]=(4 -1 2 66 10)
  # Prints the number befor sorting
  
  echo "Original Numbers in array:"
  for (( i = 0; i &lt;= 4; i++ ))
      do
        echo ${nos[$i]}
      done
  
   #
   # Now do the Sorting of numbers  
   #
  
  for (( i = 0; i &lt;= 4 ; i++ ))
  do
     for (( j = $i; j &lt;= 4; j++ ))
     do
        if [ ${nos[$i]} -gt ${nos[$j]}  ]; then
         t=${nos[$i]}
         nos[$i]=${nos[$j]}
         nos[$j]=$t
        fi
     done
  done
  
  #
  # Print the sorted number
  # 
  echo -e "\nSorted Numbers in Ascending Order:"
  for (( i=0; i &lt;= 4; i++ )) 
  do
    echo ${nos[$i]}
  done
  </code></pre>