How to sort a struct
173 次查看(过去 30 天)
显示 更早的评论
Is it possible to sort a struct? I want to sort the third column.
0 should be in the first row and the highest value at the end (last row). The other values are not important and should be the same ranking.
Thank you.
2 个评论
采纳的回答
Mohammad Sami
2020-7-23
编辑:Mohammad Sami
2020-7-23
You can try like this.
% a = somestruct;
[~,index] = sortrows([a.Var3].');
a = a(index);
2 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Structures 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!