3.5K Downloads
Updated
23 Jul 2002
No License
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://uk.mathworks.com/matlabcentral/fileexchange/1958-sort-structure), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Created with
R12.1
Compatible with any release
Platform Compatibility
Windows macOS LinuxCategories
- MATLAB > Language Fundamentals > Data Types > Structures >
- MATLAB > Language Fundamentals > Matrices and Arrays > Shifting and Sorting Matrices >
Find more on Structures in Help Center and MATLAB Answers
Tags
Acknowledgements
Inspired: Order all fields
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
| Version | Published | Release Notes | |
|---|---|---|---|
| 1.0.0.0 |
