Unfortunately you'd have to change the filenames on the system since [man]readdir/man will return the list as they are listed on the filesystem.
Typically in cases like this a number is typically prepended to the filename to delineate sorting order. Just remember that files will be listed like:
1__file.txt
10__file.txt
11__file.txt
2__file.txt
3__file.txt
4__file.txt
43__file.txt
44__file.txt
So you'll want to make sure that you number them with preceeding 0's.
001__file.txt
002__file.txt
003__file.txt
004__file.txt
010__file.txt
011__file.txt
043__file.txt
044__file.txt
Of course you could always store the info in array's and then sort the array the way you want.