I need to create a function that outputs and ordered list based on the length of the input.
The input is a struct with field name countries that contains a char vector with the abbreviations of particular countries.
i.e. struct(1).countries = 'US GB CZ'
I am using a for loop to go through each struct and countries field to determine which one has the largest amount of countries. I used the strlength() fxn to compare the lengths of the "countries" vectors, but now I need a way to ouput it in an ordered list.
I did something along the lines of
function out_out = in(struct)
for ii = 1:length(struct)
if strlength(struct(ii).countries) >= strlength(struct(ii-1).countries)
out = [struct(ii).title out]
out_out = out(:)
How can I compile all inputs into one big output list with the struct with the most countries at the top and the struct with the fewest at the bottom. Some structs may have equal number of countries. I do not want to lose any of the structs, just re-order them based on how many countries are in them.