Reputation: 81
a=[44;60;11]; b=[9;8;4]; c=[4;16;23];
T=table(a,b,c);
d=[2;3;1];
Sort rows of table T according to index vector "d"
Upvotes: 0
Views: 55
Reputation: 66
So you're sorting the rows according to the indices in your vector d.
tSort = T(d,:);
Upvotes: 2
Reputation: 23685
If I understood your question correctly, this should work as intended:
a=[44;60;11]; b=[9;8;4]; c=[4;16;23];
T=table(a,b,c);
d=[2;3;1];
T_new = T(:,d);
The last line will swap the table columns (to be exact, the table variables) according to the indices in vector d.
Upvotes: 1