MATLAB: Sorting according to another vector

sort

Hi,
I have a vector A that doesn't follow any order. I want to sort Matrix B that has the first column of values similar to those of A but in different order. Is it possible to sort B according to A using a single function or should I write many codes to do so?

Best Answer

Sorry you will have to use multiple calls:
[a_sorted, a_order] = sort(A);
newB = B(a_order,:);