%% Sort Vectors in Same Order
% Create two row vectors that contain related data in the corresponding elements.

X = [3 6 4 2 1 5];
Y = ["yellow" "purple" "green" "orange" "red" "blue"];

% First sort the vector X, then sort the vector Y in the same order as X.

[Xsorted,I] = sort(X)
Ysorted = Y(I)

% Copyright 2020 The MathWorks, Inc.