function  insertion_sort ()
{
    
    

    
    local -a arr         
    local -i i           
    local -i j
    local -i key
    local -i prev
    local -i leftval
    local -i N          

    arr=( $@ )    

    N=${
    readonly N    

    
    for (( i=1; i<$N; i++ ))  
    do
	key=$((arr[$i]))      
	prev=$((arr[$i-1]))   
	j=$i                  

	while [ $j -gt 0 ]  && [ $key -lt $prev ]  
	do
	    arr[$j]=$((arr[$j-1])) 

	    j=$(($j-1))            

	    prev=$((arr[$j-1]))    

	done

	arr[$j]=$(($key))          

    done

    echo ${arr[*]}                   
}


function main ()
{
    
    declare -a sorted

    
    if [ $
	arr=(10 8 20 100 -3 12 4 -5 32 0 1)
    else
	arr=($@) 
    fi

    echo
    echo "original"
    echo -e "\t ${arr[*]} \n"

    sorted=($(insertion_sort ${arr[*]}))  

    echo    
    echo "sorted:"
    echo -e "\t ${sorted[*]} \n"
 }   




if [[ "$0" == "bash" ]]; then 
    unset main
else
    main "$@"                 
fi