You can download this code by clicking the button below.
This code is now available for download.
This function takes a list as an argument and sorts the list by the length of each element, then returns the sorted list.
Technology Stack : Built-in function sorted, list
Code Type : Function
Code Difficulty : Beginner
def sort_list_by_length(list_to_sort):
return sorted(list_to_sort, key=len)