MATLAB's 'sortrows' gives unexpected order when sorting mixed data types in R2023b
I'm optimizing some code but I'm working with an scenario with the `sortrows` function in MATLAB R2023b when trying to sort a table that contains mixed data types. Specifically, I have a table with numeric and string data types, and I'm trying to sort first by a numeric column and then by a string column. However, the resultant order does not seem to respect the numeric sorting before the string sorting. Hereβs a simplified version of my code: ```matlab % Sample data T = table([2; 1; 2; 1], {'b'; 'a'; 'a'; 'b'}, 'VariableNames', {'Numbers', 'Letters'}); % Sorting the table T_sorted = sortrows(T, {'Numbers', 'Letters'}); disp(T_sorted); ``` After running the above code, I expected the output to be sorted first by the `Numbers` in ascending order and then by `Letters` in alphabetical order. However, the output is: ```matlab Numbers Letters ________ _______ 1 a 1 b 2 a 2 b ``` As you can see, the sorting looks correct by `Numbers`, but it seems the `Letters` column isn't being considered correctly. I attempted to cast the `Numbers` column to a categorical type, but it didn't resolve the scenario. Here's what I tried: ```matlab % Casting to categorical T.Numbers = categorical(T.Numbers); T_sorted = sortrows(T, {'Numbers', 'Letters'}); disp(T_sorted); ``` Yet, the output remained the same. Could this be a bug in R2023b, or am I missing something in the way MATLAB handles mixed data types during sorting? Any insights or potential workarounds would be greatly appreciated! I'm using Matlab 3.9 in this project. Thanks for any help you can provide!