4. Write a program to perform sorting on a given list of strings, on the basis of length of strings. That is, the smallest-length string should be the first string in the list and the largest-length string should be the last string in the sorted list.

# Code
def insertion_sort(arr):
for i in range(1,len(arr)):
key = arr[i]
j = i-1
while j >= 0 and len(key) < len(arr[j]): # comparison on the basis of length
arr[j+1] = arr[j]
j -= 1
arr[j+1] = key
return arr

l = input("Enter a list of strings : ").split() # split() splits the input on whitespace
print(insertion_sort(l))

# output
Enter a list of strings : amam abi adfjklfj fsdj
['abi', 'amam', 'fsdj', 'adfjklfj']