SORT ELEMENTS OF AN ARRAY IN LINUX

In this Blog, sharing code to sort the elements of an array in ascending and descending order as well.ASCENDING ORDER arr=(4 3 2 1) ## Array of 4 Elementslen=${#arr[@]} ## It gives the length of an Array arrk=0lngthminusone=$(( $len – 1))while [ $k -lt $len ] ##Outer Loop which will run len-1 times where len is length of Arraydoi=0 ## This variable set to 0 every time inner loop startswhile [ $i -lt $lngthminusone ] ## Inner loop which will arrange an element of an array in ascending order. Outer…