Question: Consider the basic ascending insertion sort function below: def insertion_sort(a_list): for index in range(1, len(a_list)): item_to_insert a_list[index] i = index - 1 while i >=

Consider the basic ascending insertion sort function below: def insertion_sort(a_list): for index in range(1, len(a_list)): item_to_insert a_list[index] i = index - 1 while i >= 0 and a_list[i] > item_to_insert: a_list[i + 1] a_list[i] i -= 1 a_list[i + 1] item_to_insert Modify the above function so that it will sort a list of strings by the following ordering criteria: longer words are ordered as appearing before shorter words. words of equal length are ordered alphabetically in a descending manner. Note: you may assume that the list is not empty.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!