pyassistant

String Sorting

Given a list of strings, write a function that returns the strings sorted based on their length in descending order. If two strings have the same length, they should be sorted alphabetically.

Example:

Input:
['apple', 'banana', 'pear', 'kiwi', 'orange']
Output:
['banana', 'orange', 'apple', 'pear', 'kiwi']

Make sure you return your solution, don't print!

AI

Bot

Trying to solve my challenge? Ask if you must, or press the purple button so I can analyze your code.