Sorting List by Padded ASCII Values

  • Share this:

Code introduction


This function takes a list as an argument and returns a new list where the elements are sorted in descending order based on their ASCII values. If the number has less than 10 digits, zeros are filled in front.


Technology Stack : Built-in functions: sorted, lambda expression, str.zfill

Code Type : Sort function

Code Difficulty : Beginner


                
                    
def zsort(items):
    return sorted(items, key=lambda x: x.zfill(10))