sorting an string cell

조회 수: 8 (최근 30일)
Muhammad
Muhammad 2021년 6월 1일
편집: Stephen23 2023년 8월 14일
i have cell whoes 1st column has names of countries and 2nd have population
i want to arrage it alphabetical oder in such a way so that population of counteries donot misplaced
for example
burundi 11890781 donot change means row wise data donot alter
  댓글 수: 4
Stephen23
Stephen23 2021년 6월 1일
@Muhammad SULAMAN: then you will need to handle the diacritics yourself (e.g. remove them before sorting and then use the sort index to sort the original data).
Stephen23
Stephen23 2023년 8월 14일
편집: Stephen23 2023년 8월 14일
Addendum: an easy way to sort Réunion into the expected position is to use ARBSORT:
For example:
S = ["Réunion","Zambia","Rwanda","Angola"];
sort(S) % for comparison
ans = 1×4 string array
"Angola" "Rwanda" "Réunion" "Zambia"
arbsort(S)
ans = 1×4 string array
"Angola" "Réunion" "Rwanda" "Zambia"

댓글을 달려면 로그인하십시오.

채택된 답변

Rik
Rik 2021년 6월 1일
You can use sortrows directly, or use code like this:
[~,order]=sort(population(:,1));
population=population(order);
  댓글 수: 4
Muhammad
Muhammad 2021년 6월 1일
output of your code
it doesnot have populatioin
Stephen23
Stephen23 2021년 6월 1일

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by