Sorting Tuples by First Word Alphabetically

  • Share this:

Code introduction


This function takes a list of tuples containing words and returns a new list sorted based on the alphabetical order of the first word in each tuple.


Technology Stack : List (list), Tuple (tuple), String (string), Alphabetical order sorting

Code Type : Function

Code Difficulty :


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