Matlab - sort cell array of objects by property -


suppose had class named foo, datenum property named datetime. if had cell array collection of foo objects, how sort according each object's datetime property?

i have seen references overloading sort method , working arrays of objects, i'm using cell array due dynamic sizing , instructions aren't holding up. got suggestions? cheers

the simplest approach extract time-values vector, sort that, , use new order sort original array.

%# extract datetime cell array foocell datetime = cellfun(@(x)x.datetime, foocell);  [~,sortidx] = sort(datetime);  %# reorder foocell foocell = foocell(sortidx); 

Comments

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

php - Boolean search on database with 5 million rows, very slow -

css - Text drops down with smaller window -