diff --git a/snippets/qsort.sh b/snippets/qsort.sh index 9db7f7f..0be604e 100755 --- a/snippets/qsort.sh +++ b/snippets/qsort.sh @@ -24,8 +24,39 @@ qsort() { array=(a c b "f f" 3 5) + qsort "${array[@]}" +echo "" +echo "" + +echo " The original array was:" +echo " =======================" +printf " %s\n" "${array[@]}" + +echo "" + +echo " Print sorted array 'qsort_ret' using 'printf'.." +echo " ===============================================" +printf " %s\n" "${qsort_ret[@]}" + +echo "" + +echo " Print sorted array 'qsort_ret'using 'for'-loop.." +echo " ================================================" +# the quotes between '${qsort_ret[@]}' are very important +# +for _val in "${qsort_ret[@]}" ; do + echo " $_val" +done + +echo "" + +echo " Output of command \033[1mdeclare -p qsort_ret\033[m.." +echo " =====================================================" +echo "" + declare -p qsort_ret +echo -e "\n" exit 0