Sort Structure

Sort fields in ascending order.

You are now following this Submission

It really bugged me that MATLAB automatically adds a new field in a structure at the end of that structure.

This function remedies that problem. After you add a new field, just sort it with this function and everything is put into the right order again.

Notice that this function also sorts the structures within the structures and puts them at the beginning, before the other fields.

Cite As

Mark Jobse (2026). Sort Structure (https://www.mathworks.com/matlabcentral/fileexchange/1958-sort-structure), MATLAB Central File Exchange. Retrieved .

Acknowledgements

Inspired: Order all fields

General Information

MATLAB Release Compatibility

  • Compatible with any release

Platform Compatibility

  • Windows
  • macOS
  • Linux
Version Published Release Notes Action
1.0.0.0