MATLAB: Putting files with numeral string names into numeric order

sort

I am trying to sort the order of some experiment files in a directory. The software package that generates the files uses internally generated file names. There are a total of 50 files. The file name comes up something like 'eight00000.T000.D000.P001.H001.CFD.txt. I know that the directory command 'dir' will produce a list of files in the order of 'eight000000','eighteen000000','eleven000000','fifteen000000' and so on. I need to put the files into a numeric order, so 'zero','one','two','three' but be able to reverse the sort order.
I have tried using regexp() and sort () without success.
Any thoughts?

Best Answer

I don't know how many these go up to, but assuming it's only fifty or so, I'd just call dir for each word and concatenate all the results. Sure it's 50 lines of code but that's not many and it's easy and straightforward. You can just toss all the lines into a function or something - no big deal and simpler than trying to use regexp or sort (as you already know).
folder = pwd; % Can be whatever you want.
files = dir(fullfile(folder, 'one*.*'))
files = [files; dir(fullfile(folder, 'two*.*'))];
files = [files; dir(fullfile(folder, 'three*.*'))];
files = [files; dir(fullfile(folder, 'four*.*'))];
files = [files; dir(fullfile(folder, 'five*.*'))];