The array elements (Strings) are taken as input. Strings within the array are sorted here using bubble sort. The in-built functions are used here to sort the strings of the array.
INPUT: The array of strings
OUTPUT: the sorted array of string
PROCESS:
Step 1: [taking the inputs]
Read n [number of elements]
For i=0 to n repeat
Read a[i]
[End of ‘for’ loop]
Step 2: [Sorting the array]
For i=0 to n repeat
For j=i+1 to n repeat
if(arr[i]>arr[j]) then
swap arr[i] with arr[j]
[End of ‘if’]
[End of ‘for’ loop]
[End of ‘for’ loop]
Step 3: Stop.
Related