I have the two inputs and my output
Sorted_Array = ['Historic Rate', 'Overnight', '1M', '3M', '6M', '1Y', '2Y', '3Y', '4Y', '5Y', '6Y', '7Y', '8Y', '9Y', '10Y', '12Y', '15Y']
Input = ['6M', '2Y', '7Y', '1Y']
Output = ['7Y', '1Y', '6M', '2Y']
the output is unintuitive, it should be
Actual_Output = ['6M','1Y','2Y','7Y']
the code I use is:
Ouput = [x for _, x in sorted(zip(Sorted_Array,Input), key=lambda pair: pair[0])]
print(Output)
Can anyone see where this has gone wrong?
zip(Sorted_Array,Input)looks like ? The output is what one would expect. I don't know what you're trying to do but obviously you're doing it wrong ;-)