Custom Sort in python ------------------------------------ Have been given a lot of words, all different. You are to
Question:
Custom Sort in python ------------------------------------ Have been given a lot of words, all different. You are to sort them as per the following requirements: Sort the words by length: the longest word first. If the length of two words is the same, compare the first letter of both the words. The letter that is lower on the lexicographical order is placed above the one that appears higher on the order. If a tie still exists, then compare the last letters. The letter that is lower on the lexicographical order is placed above the one that appears higher on the order. If a tie still exists, compare the second letters. The letter that is lower on the lexicographical order is placed above the one that appears higher on the order If a tie still exists, compare the second last letters. The letter that is lower on the lexicographical order is placed above the one that appears higher on the order And so on. Note- Lexicographical order is (A(lowest), B, C, D, … X, Y, Z(highest) ) Input: A list of words. Output: A list of the same words sorted according to the instructions in the question. Sample input [laptop, Mobile, moaile, mobize, Car] Sample output [laptop, moaile, Mobile, mobize, Car]