Sort Tuples by First Element

  • Share this:

Code introduction


This function takes a list of tuples as input and sorts the list based on the first element of each tuple.


Technology Stack : list, tuple, dict comprehension, lambda expression

Code Type : Sort function

Code Difficulty : Intermediate


                
                    
def aordify_list(input_list):
    return sorted(input_list, key=lambda x: x[0])