Sorting List by Dictionary Values

  • Share this:

Code introduction


This function sorts the list `arg1` based on the corresponding values in the dictionary `arg2`.


Technology Stack : Built-in function sorted, lambda expression

Code Type : Sort function

Code Difficulty : Intermediate


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