How can I sort valus of a field in struct?
1 view (last 30 days)
Show older comments
Mira le on 30 Apr 2021
Commented: Mira le on 1 May 2021
I have an issue to sort values so
I have struct named R contains field : sequance [ ]
Cost [ ]
I want to sort R according to weights in ascending order
please help me.
Is R a scalar struct or a struct array? Are the contents of the weights field scalars?
[~, index] = sort([R.weights]);
sortedR = R(index)
More Answers (0)
Find more on Structures in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!