Sorting List by Dictionary Values

  • Share this:

Code introduction


The function sorts the list `arg1` based on the values of each element in the dictionary `arg2`. The keys of the dictionary correspond to the elements of the list, and the values correspond to the sorting criteria.


Technology Stack : sorted, lambda expression, dictionary

Code Type : Function

Code Difficulty : Intermediate


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