If I understand your use case correctly, you can employ MATLAB's matrix indexing ability (see http://www.mathworks.com/company/newsletters/articles/MatrixIndexinginMATLAB/matrix.html) instead of generating a transformation matrix.
For example, if this is your input vector:
a = [0 1 2 3 4 5 6 7]
and your "sort vector" is:
s = [0 2 4 6 1 3 5 7]
(meaning generate the output vector such that it contains element 0 of the input vector at position 0, element 2 of the input at position 1, element 4 of the input at position 2, etc.)
you can simply use matrix indexing to produce your desired output:
b = a(s+1);
(The "+1" is required because MATLAB uses 1based matrix indexing; alternatively, number the indices in your sort vector from 1 to N rather than from 0 to N1.)
For example (this is a general case; the even/odd indices case is covered below):
a = [0 4 2 3 1]
s = [1 5 3 4 2]
b = a(s) produces b = [0 1 2 3 4]
Since it appears that you want all the evenindexed entries in the first half of your result and the oddindexed ones in the second half, your sort vector could be generated as follows (using MATLAB's 1based indexing):
s = [2:2:numel(a) 1:2:numel(a)]
Hope that helps.
Will
