Filter löschen
Filter löschen

sorting an string cell

12 Ansichten (letzte 30 Tage)
Muhammad
Muhammad am 1 Jun. 2021
Bearbeitet: Stephen23 am 14 Aug. 2023
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 Kommentare
Stephen23
Stephen23 am 1 Jun. 2021
@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 am 14 Aug. 2023
Bearbeitet: Stephen23 am 14 Aug. 2023
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"

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Rik
Rik am 1 Jun. 2021
You can use sortrows directly, or use code like this:
[~,order]=sort(population(:,1));
population=population(order);
  4 Kommentare
Muhammad
Muhammad am 1 Jun. 2021
output of your code
it doesnot have populatioin

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by