function B = sortBlikeA(A,B)
[~, A_index] = sort(A);
Bs=sort(B);
B(A_index)=Bs;
end
按照A的大小排布顺序对B排序
>> A=[4 1 3 2];
>> B='abcd';
>> sortBlikeA(A,B)
ans ='dacb'
>> a=[10,9,17,30,20];
>> [b,c]=sort(a)
b = 9 10 17 20 30 c = 2 1 3 5 4
a(c(1))就是最小,a(c(2))第二最小,依次类推