Advertisement
here2share

# sort_by_paired_lists.py

Jun 23rd, 2025
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.20 KB | None | 0 0
  1. # sort_by_paired_lists.py
  2.  
  3. list_a = ['a4', 'b3', 'c1', 'd2']
  4. list_b = [4, 3, 1, 2]
  5.  
  6. sorted_a = list(map(lambda pair: pair[1], sorted(zip(list_b, list_a))))
  7. print(sorted_a) # ['c1', 'd2', 'b3', 'a4']
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement