How to sort rows in a matrix of strings according to a specific char?
1 回表示 (過去 30 日間)
古いコメントを表示
For example, I want to sort this matrix:
A = ['1C3489' ; '2E1919' ; '0A8721' ; '8B1821']
according to the letters (the 2nd char in each row), so the result will be:
A_sorted = ['0A8721'; '8B1821'; '1C3489'; '2E1919']
I didn't understand if the function "sort" knows how to do it.
0 件のコメント
採用された回答
Jonas
2021 年 4 月 25 日
easily possible,
A = ['1C3489' ; '2E1919' ; '0A8721' ; '8B1821']; sortrows(A,2)
the chars can dirextly be interpreted as numbers, e.g. char(97) is equal to 'a'
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Shifting and Sorting Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!