%% List Fields by Position Using Permutation Vector
% Create a structure.

data.x = linspace(0,2*pi);
data.y = sin(data.x);
data.title = 'y = sin(x)'

%
% Order the fields by listing their original positions in a different order. For example, move the third field so that it is the first field of the output structure.

P = [3 1 2];
data = orderfields(data,P)

% Copyright 2018 The MathWorks, Inc.