Hello,
I find myself with a curious problem: I need to order the variables of a table without knowing in advance if all the variables will be present. I mean, I know what all the possible variables might be (possible_vars), and I know in what order I want them (desired_order). But I dont know if all the variables will be present (at least some of them will be but I dont know which ones). And if a variable is missing then it is missing, thats fine. The desired order should be kept just without that variable.
So how could I order table t below based on the desired order but without knowing in advance what all the variables will be ?
posible_vars = {'x', 'p', 'o', 'v', 's', 'a'}desired_order = {'a', 'v', 'o', 'v', 's', 'x'}% data
x = [1:3]';a = {'A';'B';'C'};o = {'A';'B';'C'};t = table(x, a, o)
Best Answer