MATLAB: Grouping Variables using rowfun Function Rearranging Order to Alphabetical

MATLAB and Simulink Student Suitename ordering using rowfun for grouping variables

How does one keep the original sequencing of variables used for matching in the rowfun?
% Guillaume's Code from Prior Question
data = readtable('ML_Q_3.xlsx', 'ReadVariableNames', false);
%optionally, give better name to the variables of the table
%data.Properties.VariableNames = {'???', '????'}
data = rmmissing(data); %get rid of empty rows
sorted = rowfun(@(v) {v}, data, 'GroupingVariables', 1); %group column 2 by column 1
The resulting sorted names are in alphabetical order (col 1) ['A','B','F','R','X'] .
Where I require it to be per the original ['B','F','R','X','A'] .
I can not find anything in the documentation rowfun how to specify to keep the original order.

Best Answer

unique() with 'stable' option. Take the third output and use it as the grouping for splitapply()