Sorting cell arrays with characters and numbers
Show older comments
Given a cell array such as {'a1', 'a2', 'a3'...'a9', 'a10', 'a11','a12'}, in random order ofcourse, using the sort function gives me {'a1', 'a10', 'a11','a12','a1','a2',...'a9'}. What method can be used to get the right order?
Accepted Answer
More Answers (1)
Walter Roberson
on 30 Oct 2022
Edited: Walter Roberson
on 30 Oct 2022
0 votes
MATLAB already gives the "right" order, just not the order you want.
https://www.mathworks.com/matlabcentral/fileexchange/34464-customizable-natural-order-sort
Categories
Find more on Shifting and Sorting Matrices in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!