How to sort a struct
136 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Peter Meier
il 23 Lug 2020
Commentato: Stephen23
il 23 Lug 2020
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 Commenti
Risposta accettata
Mohammad Sami
il 23 Lug 2020
Modificato: Mohammad Sami
il 23 Lug 2020
You can try like this.
% a = somestruct;
[~,index] = sortrows([a.Var3].');
a = a(index);
2 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Shifting and Sorting Matrices in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!