I got two arrays:
let arrayValues = [["20", "."], ["42", "."], ["44", "."], ["6", "."], ["5", "."]]
let arrayIndex = [4,5,1,2,3]
and I got one Problem:
I'd like to sort the values array based on the numbers of the index Array - (note that the first Element is connected to the first Element, the second one to the second and so on) - so that the highest number comes first, the second next and so one. This order needs to be translated to the first array.
The result should be this:
let result = ["42", "."], ["20", "."], ["5", "."], ["6", "."], ["44", "."]]
because of the new order
= [5,4,3,2,1]
I now my question deals with a super special problem - but I got no idea how to start tbh.
Any help would be really appreciated.
Heres my python code:
arrayValues = (("20", "."), ("42", "."), ("44", "."), ("6", "."), ("5", "."))
arrayIndex = (4,5,1,2,3)
result = sorted(range(len(arrayValues)), key=lambda i:arrayIndex[i],reverse=0)