Sorting Words by Length

  • Share this:

Code introduction


This function takes a list of tuples containing words and their lengths and returns the list sorted by the length of the words.


Technology Stack : tuple, list, lambda expression, sorting

Code Type : Function

Code Difficulty : Intermediate


                
                    
def sort_words(words):
    return sorted(words, key=lambda x: x[1])