MATLAB Answers


Any possibilities of using sortrows for strings

Salad Box さんによって質問されました 2019 年 5 月 20 日
最新アクティビティ Adam Danz
さんによって コメントされました 2019 年 5 月 21 日
I have a cell named 'b' consisted of n by 1 of strings, each row in a cell is a string. See below.
The 1,2,3,4 is not b's original order. the original order is a = [3 1 4 2], which means 'hello world' should be in the 1st row, 'hello' should be in the 2nd row, 'world hello' should be in the 3rd row, and 'world' should be in the 4th row.
How to achieve this? How to comebine 'a' and 'b' and by sorting 'a' it also sort 'b'?
Use a table? Matrix? Cell? which one I could apply 'sortrows'?

  0 件のコメント

サインイン to comment.

1 件の回答

Adam Danz
回答者: Adam Danz
2019 年 5 月 20 日
編集済み: Adam Danz
2019 年 5 月 21 日

If I'm understanding correclty, no need for sortrows().
b = {'hello';'world';'hello world';'world hello'};
a = [3 1 4 2];
ans =
4×1 cell array
{'hello world'}
{'hello' }
{'world hello'}
{'world' }

  2 件のコメント

Salad Box 2019 年 5 月 21 日
Thanks Adam! That is exactly what I was expecting for!
Adam Danz
2019 年 5 月 21 日
Glad I could help!

サインイン to comment.

Translated by