Very ugly, but works:
UnsortedText = {'BBB 1'; 'AAA 10'; 'AAA 9'; 'AAA 1'; 'BBB 2'; 'BBB 19'; 'BBB 9'; 'CCC 0'; 'CCC 9' ;'CCC 80'; 'CCC 7'};
R = cell2mat(regexp(UnsortedText ,'(?\D+)(?\d+)','names'));
tmp = sortrows([{R.Name}' num2cell(cellfun(@(x)str2double(x),{R.Nums}'))]);
SortedText = strcat(tmp(:,1) ,cellfun(@(x) num2str(x), tmp(:,2),'unif',0))
There's got to be a simpler way to do this... Answer from Teja Muppirala on mathworks.com
MathWorks
mathworks.com › matlab › data import and analysis › data preprocessing
sort - Sort array elements - MATLAB
String input array is not supported. If the input array is a cell array of character vectors and variable sizing is disabled, all character vector elements must be the same length. In the generated code, the input array remains complex, even if all of its elements have zero-valued imaginary parts. Under these circumstances, the results produced by the generated code might differ from those produced by MATLAB...
Videos
MathWorks
mathworks.com › matlabcentral › answers › 499355-sorting-string-based-on-the-value-in-it
sorting string based on the value in it - MATLAB Answers - MATLAB Central
January 8, 2020 - Write custom sort function such as selection sort or bubble sort to sort the list of strings based on the numeric value extracted. Here is some dummy code which might be helpful in better understanding of the solution. ... In the code provided above we have used find function from MATLAB whose documentation you can refer in the attached link below.
MathWorks
mathworks.com › matlabcentral › answers › 767877-how-to-sortrows-by-specific-strings
How to sortrows by specific strings - MATLAB Answers - MATLAB Central
March 9, 2021 - How to sortrows by specific strings. Learn more about table, sortrows, sort, sorting strings MATLAB
MathWorks
mathworks.com › matlabcentral › answers › 775907-write-a-code-to-sort-string
write a code to sort string - MATLAB Answers - MATLAB Central
March 17, 2021 - Because once you have that, then my example is sorting by that value. ... Thank you a lot Walter Roberson, I just started Matlab learning and some in the example you gave, I'm a little confused about [~,idx] and A(idx); I highly appreciate your help.
MathWorks
mathworks.com › matlabcentral › answers › 160763-how-to-sort-strings-by-lenght
How to sort strings by lenght? - MATLAB Answers - MATLAB Central
October 31, 2014 - Hi, I want to do this: >> A = ['adam ' 'bertil' 'cesar ' 'Ada ' 'berit ']; >> Asort = charsort(A) Asort = Ada adam cesar ...
MathWorks
mathworks.com › matlabcentral › answers › 229757-sorting-an-array-of-strings-based-on-number-pattern
Sorting an array of strings based on number pattern - MATLAB Answers - MATLAB Central
July 14, 2015 - https://www.mathworks.com/matlabcentral/answers/229757-sorting-an-array-of-strings-based-on-number-pattern#answer_185969
MathWorks
mathworks.com › matlabcentral › answers › 379807-how-can-i-sort-strings-using-only-a-piece-of-them
How can I sort strings using only a piece of them? - MATLAB Answers - MATLAB Central
January 30, 2018 - number = str2double(regexp(A, '\d+', 'match', 'once')); %the regexp extract the first string of digits from each char array. ... Sign in to comment. Sign in to answer this question.
MathWorks
mathworks.com › matlabcentral › answers › 44721-advanced-sorting-of-cell-array-of-strings
advanced sorting of cell array of strings - MATLAB Answers - MATLAB Central
July 28, 2012 - advanced sorting of cell array of strings. Learn more about sort, cell array, textual list, strings MATLAB, Signal Processing Toolbox
MathWorks
mathworks.com › matlabcentral › answers › 1676659-sorting-a-string-by-the-use-of-another-predetermined-string-order
Sorting a string by the use of another predetermined string order - MATLAB Answers - MATLAB Central
March 21, 2022 - Sorting a string by the use of another... Learn more about sort, strings, string MATLAB
MathWorks
mathworks.com › matlabcentral › answers › 254020-sorting-a-table-with-strings-and-numbers
Sorting a table with strings and numbers - MATLAB Answers - MATLAB Central
November 10, 2015 - Then use sortrows() to sort the table based on the column with strings in it. Let's say that the column with strings is the first column, like in the example below. Then you'd just do: LastName = {'Smith';'Johnson';'Williams';'Jones';'Brown'}; ...
MathWorks
mathworks.com › matlabcentral › fileexchange › 34464-customizable-natural-order-sort
Customizable Natural-Order Sort - File Exchange - MATLAB Central
December 28, 2024 - Alphanumeric sort the text in a string/cell/categorical array. Sorts the text by character code taking into account the values of any number substrings. Compare for example: ... By default NATSORT interprets all consecutive digits as integer numbers, the number substring recognition can be specified using a regular expression, allowing the number substrings to have: ... Stephen23 (2025). Customizable Natural-Order Sort (https://www.mathworks.com/matlabcentral/fileexchange/34464-customizable-natural-order-sort), MATLAB Central File Exchange.
MathWorks
mathworks.com › matlabcentral › answers › 642595-how-to-sort-a-string-by-case-and-put-in-alphabetical-order
How to sort a string by case and put in alphabetical order? - MATLAB Answers - MATLAB Central
November 10, 2020 - The function receives a character array as input. The function must return a sorted version of the array (in ascending order) in which the first part of the array contains the sorted version of the...
MathWorks
mathworks.com › matlabcentral › answers › 1848073-sort-a-string-array-according-to-equivalent-names-of-another-string-array
Sort a string array according to equivalent names of another string array - MATLAB Answers - MATLAB Central
November 10, 2022 - I'm trying to sort string array "S1" according to the order of the equivalent string names in the string array "names". New to Matlab so I would tend towards comparing and looping, but hoping there...
MathWorks
mathworks.com › matlabcentral › answers › 1693945-how-to-re-order-a-string-array
How to re-order a string array? - MATLAB Answers - MATLAB Central
April 11, 2022 - currently the files are orderd like this, the value increasing by 30 each time up to 1830: however, with the code i've used, matlab orders the files like this: is there any way i can sort the...