MATLAB: Alphanumeric sorting of data

alphanumericascendingsort

Hello,
I have data which is extracted from various excel fiels in a folder. I want to sort the data based on the data in the first column. The issue is the data in this column is for ex, '10000 Rest', '3200 Rest', '2000 Rest', etc.. I need the data to be in ascending form. The output I receive is '10000 Rest', '2000 Rest', '3200 Rest', etc. The required output for me is '2000 Rest', '3200 Rest', '10000 Rest'.. etc.
Is there a way to change the sorting type.
Thanks

Best Answer

Hi,
Based on my understanding of the issue, I suggest you to implement the 'sort_nat' function. The function is used to sort array of strings in natural alphabetcial order. I have added a reference example code below to demonstrate the use of sort_nat function.
arr = {'10000 Rest','3200 Rest','2000 Rest'};
sort_nat(arr);
Hope this helps!