Sorting Names by Length in Python

  • Share this:

Code introduction


This function takes a list of names as input, sorts them by the length of the names, and returns the sorted list.


Technology Stack : list, sorting, key

Code Type : Function

Code Difficulty : Intermediate


                
                    
def sorted_names_by_length(names):
    return sorted(names, key=len)                
              
Tags: