On May 30, 11:54 pm, Marco Lazzaretti <
marco.lazzarett...@gmail.com>
wrote:
"Position vector" is an ambiguous term.
You need to distinguish between "to" lists and "from" lists.
The list of indices returned by Ordering is a "from" list:
the k'th element specifies where in the original list
the k'th element in the reordered list came *from*.
However, your position_vector1 seems to be a "to" list:
the k'th element specifies the position in the new list
that the k'th element in the old list should go *to*.
Ordering toggles between the two kinds of lists.
In[1]:= v1 = {32,4,28,11,20};
In[2]:= o1 = Ordering@v1
p1 = Ordering@o1
o1 === Ordering@p1
Out[2]= {2,4,5,3,1}
Out[3]= {5,1,4,2,3}
Out[4]= True
In[5]:= v2 = {78,12,95,14,35};
In[6]:= v2[[o1]]
v2[[p1]]
Out[6]= {12,14,35,95,78}
Out[7]= {35,78,14,12,95}