Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # swapsort_list_a_via_list_b_by_index.py ### generic version
- import random
- val = [9,8,7,6,5,4,3,2,1]
- cue = ['a', 1, 'b', 'c', 2, 3, 'd', 'e', 'f', 4]
- def swap():
- swap=[]
- for z in range(len(cue)):
- if cue[z] in val:
- swap.append([val.index(cue[z]),cue[z]])
- cue[z]=''
- swap = [z[1] for z in sorted(swap)]
- for z in swap:
- cue[cue.index('')]=z
- return cue
- #
- print swap()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement