Sorting List of Strings by ASCII Value of First Character

  • Share this:

Code introduction


This function accepts a list of strings as an argument and returns a sorted list, with the sorting based on the ASCII value of the first character of each string in the list.


Technology Stack : list, string, sorting, lambda expression

Code Type : Sort function

Code Difficulty :


                
                    
def aordify(items):
    return sorted(items, key=lambda x: ord(x[0]))