Note: I should be clear my desire is to do this functionally, in one statement. I can do this easily with loops but that's not what I'm interested in.
I have two arrays: a numeric array of indexes, A, and an associative array, B, of objects O indexed by the elements of array A.
I want to produce an array of O in the order of the elements of A--in other words, map the indexes into real objects, based on the associative array B.
For example:
A = [ 3, 4, 2, 1 ];
B = [ 1=>"one", 2=>"two", 3=>"three", 4=>"four" ]
I want:
[ "three", "four", "two", "one" ]
Also, incidentally I'm also curious to learn what this concept is called. It's kind of like mapping, but specifically involves indexes into another array, as opposed to a function.