code: def sort_against(list1, list2, reverse=False):
      
      try:
          return [item for _, item in 
                  sorted(zip(list2, list1), key=lambda x: x[0], reverse=reverse)]
      except:
          return list1
docs: Arrange items of list1 in the same order as sorted(list2).
  
      In other words, apply to list1 the permutation which takes list2 
      to sorted(list2, reverse).