tuple1 = (4, 1, 3)
tuple2 = (9, 8, 6)
tuple3, tuple4 = get_sorted_in_parallel(tuple1, tuple2)
print(tuple1, "-", tuple2)
print(tuple3, "-", tuple4)prints:
(4, 1, 3) - (9, 8, 6)
(1, 3, 4) - (8, 6, 9)
def get_sorted_in_parallel(tuples1, tuples2):
def get_sorted_in_parallel(tuples1, tuples2):
kv={}
index=0
for item in tuples1:
kv[item]=index
index+=1
lst=list(tuples1)
lst.sort()
tuples1=tuple(lst)
lst=[]
for item in tuples1:
lst.append(tuples2[kv[item]])
return tuples1,tuple(lst)
tuple1 = (4, 1, 3)
tuple2 = (9, 8, 6)
tuple3, tuple4 = get_sorted_in_parallel(tuple1, tuple2)
print(tuple1, "-", tuple2)
print(tuple3, "-", tuple4)