MATLAB: Order two related vectors

orderingsortvectors

Hi, I have 2 vectors: one numeric vector and a string vector ( a cell array to be exact). String one refers to value one, string two to value two and so on. I want to sort the numeric vector and, according to the result, order the string vector too, for example:
v1 v2 2 "my name is" 1 "hello" 3 "Bob"
after the ordering v1 v2 1 "hello" 2 "my name is" 3 "bob"
How can I accomplish this?

Best Answer

For example:
A = [3 1 4 2];
B = {'Bob' 'Jeff' 'Mike' 'Len'};
[As,I] = sort(A);As
Bs = B(I)