This is an update to a previous question about reordering in place There was some confusion about the vector of indices. Calling the vector to be reordered vA, and the vector of indices vI, then vA should be reordered in this order, vA[vI[0]], vA[vI[1]], vA[vI[2], ... . An example usage would be to initialize vI as a set of vA.size() indices, 0 to vA.size()-1, then sort vI according to vA (compare using vA[vI[...]]). Then the reorder function could be used to sort vA according to vI.
Consider the initial vA as a permutation of a sorted vA. After sorting vI according to vA, then reordering vA according to vI "unpermutes" vA back to the sorted permutation. With the example functions shown below, reordering vA also reorders vI back to it's initialized state (0 to vA.size()-1).