%% Order Fields Using Another Structure
% Create two structures that have the same fields, in different orders. The field names are the same, but the field values are different.

S1 = struct('b',1,'B',2,'a',3,'A',4)

%

S2 = struct('a',0,'b',20,'B',10,'A',0)

%
% Order the fields in S1 to match the order of fields in S2.

S = orderfields(S1,S2)

% Copyright 2018 The MathWorks, Inc.