sort() help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
wuluan15
Forum Newbie
Posts: 2
Joined: Wed Oct 13, 2010 9:43 am

sort() help

Post 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?
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: sort() help

Post 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().
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
wuluan15
Forum Newbie
Posts: 2
Joined: Wed Oct 13, 2010 9:43 am

Re: sort() help

Post 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().
Post Reply