Sorting Function Based on Dictionary Values

  • Share this:

Code introduction


A sorting function that sorts the elements of arg1 based on the values in the dictionary arg2.


Technology Stack : Built-in function sorted, dictionary comprehension

Code Type : Sort function

Code Difficulty : Intermediate


                
                    
def aordnsl(arg1, arg2):
    return sorted(arg1, key=lambda x: arg2[x])