Sorting List by Order of Another List Elements

  • Share this:

Code introduction


This function takes two lists as arguments, and the elements in the first list will be sorted according to the order of the corresponding elements in the second list.


Technology Stack : List, Sorting

Code Type : Function

Code Difficulty : Intermediate


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