Say I have a struct:
MyStruct.a = 12; MyStruct.b = 22; MyStruct.c = 32;
Can I modify it so that the fields are ordered based on their value:>
% Define initial structure: myStruct.a = 12; myStruct.b = 22; myStruct.c = 32; % Find desired order of values, rather than fieldnames: [ ~,sortIdx ] = sort( structfun( @(x) x, myStruct ), 'descend' ); % Apply orderfields(): mySortedStruct = orderfields( myStruct, sortIdx )