Sort Matlab table based on pre-defined order
Mostra commenti meno recenti
I would like to sort a table based on a column that only contains 4 string values (A, B, C, and d) in an specific order that is not alphabetic.
This is what I am currently using:
sortrows(table_1,{'col1','col2'},{'ascend' 'descend'})
For col2 I would like to use a custom order that is neither ascend nor descend. So for instance the sorting order should be:
B
A
C
D
Risposta accettata
Più risposte (1)
Turlough Hughes
il 31 Gen 2022
Try the following:
idx = [2 1 3 4];
T(idx,:) = T
1 Commento
Metin Akyol
il 31 Gen 2022
Categorie
Scopri di più su Shifting and Sorting Matrices in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!