Page 1 of 1

sort() help

Posted: Wed Oct 13, 2010 9:50 am
by wuluan15
i'm trying to print a sorted list of filenames by doing:

$map = scandir('../download/'.$username.'/');

but when i print it, the sorting is divided in to two groups, here is the output:
--------------
.
..
3420.jpg
Biker-Mice From Mars # SNES.SMC
DXSETUP.exe
Getting Started.[1].pdf
Getting Started.[2].pdf
Getting Started.pdf
SCPH1001.BIN
VLC.lnk
a2_commands.txt // group two starts here
artifacts.xml
dps.sub
dxupdate.cab
extra3.jpg
main.[1].css
main.css
put_memcards_here.txt
--------------------------

i was hoping they would be sorted as one group. any ideas why this is happening?

Re: sort() help

Posted: Wed Oct 13, 2010 10:06 am
by AbraCadaver
It's the difference in the case of the character. The ASCII codes for lowercase characters are higher than uppercase characters. Try natcasesort().

Re: sort() help

Posted: Wed Oct 13, 2010 10:09 am
by wuluan15
Thanks, i would never have noticed that :)
AbraCadaver wrote:It's the difference in the case of the character. The ASCII codes for lowercase characters are higher than uppercase characters. Try natcasesort().