Click here to Skip to main content
15,886,822 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a webpage that calls a PHP function that returns a list of files in a folder then displays them as a list view
The files are text files that go as follows
Order1.txt
Order2.txt
Etc..
Order10.txt
Order11.txt

The problem I have is when they are displayed in the listview, they come out as

Order1.txt
Order10.txt
Order11.txt
Order2.txt
Etc...

I need in order 1 to whatever in order. I’m not able to change the format of the saved files

Can anyone suggest anything? I’m struggling with what I thought would be simple!

What I have tried:

I’ve tried a few things on sorting list views and they work for alphabetical but not for this because of the numbering, which I can’t change
Posted
Updated 5-Jan-21 1:04am

1 solution

The problem is the file names.
You should name them Order01.txt, Order02.txt etc.
instead of Order1.txt, Order2.txt etc.
 
Share this answer
 
Comments
Member 10501006 5-Jan-21 7:43am    
I can’t rename the files in the directory, they are produced by another piece of software and I really don’t want to have to mess around renaming files
thatraja 5-Jan-21 9:21am    
String sort works that way only so the other software should rename files with pre 0s(like Order01.txt, Order02.txt).

Think about 3 & 4 digit numbers file names like Order100.txt, Order101.txt. That time 1st file should be named like Order001.txt instead of Order01.txt. Inform this to other software vendor to make changes.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900