Jump to content

how to order the usernames out of a table by the alphbet


BillyBoB

Recommended Posts

a note about sort:  it doesn't sort the items alphabetically as one would expect, even if you specify comparison as strings.  in the case that you want array items sorted as a human would alphabetically sort them, use natsort() or natcasesort() (the latter being a case-insensitive version of the natural sort).

and yes, i know this post has strayed off-topic, but i figured i'd point it out while sort() was being mentioned.
i couldn't really tell, it was a little erratic.  i had an array of filenames, of which a few started with numbers, others with upper case and others with lower case.  i believe it processed them in the order of number in numeric order, upper case in alpha order, lowercase in alpha order.  i was using sort($array, SORT_STRING).

i ended up using natcasesort(), and it fixed the issue.
Ah ok, looks like the manual says pretty much the same:
[quote]
Warning
Be careful when sorting arrays with mixed types values because sort() can produce unpredictable results.
[/quote]

Looks like sort would do the job for just text though.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.