0

Similar to this, but in python.

I have two lists. List a contains a set of numbers and List b contains a set of strings, with the 2 lists having corresponding indexes. For example:

a = [9,12,25,3,2,3,1]
b = ['jim','bob','cal','tim','pete','bill','jane']

9 corresponds to jim, bob to 12, etc. I want to sort list a by value (greatest to least), but keep the original correspondence. The new lists would be:

new_a = [25,12,9,3,3,2,1]
new_b = ['cal','bob','jim','tim','pete','bill','jane']

or something like {new_a_item_sorted:new_b_item_corresponding}, etc.

THIS QUESTION IS DIFFERENT BECAUSE:

  • I want the original list sorted as well
Community
  • 1
  • 1
retep
  • 317
  • 2
  • 13

0 Answers0