Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
|
No.
Your problem is that the sort function sort by the first characters in the string. In your case, 010, 101, etc...
The sorting is right upon that criteria.
Sort have 1 parameter that you can give to alter it's algorithm, but from what I see, you will need to sort not on the full file name, but on a substring of the file name, ignoring the first numeric part.
Am I right ?
If so, you will need to create an "reference" array, and the real files array.
The reference will hold the shortened name only, and the real files array which will not be numerical but indexed by strings.
What I mean is that you need to create it like this:
PHP Code:
$shortName=myShorteningFunction($fullName); $aryFiles[$shortName]=$fullName;
This will create an array, but it will index it via a string, and not a number.
You order the reference array, and after it's sorted, you iterate through it.
For each short name, you call the corresponding value in the longName array.
PHP Code:
sort($aryRef); foreach($aryRef as $shortName){ echo $aryFiles[$shortName]; }
__________________
Only a biker knows why a dog sticks his head out the window.
|