Array multi sort by keys

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
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

Array multi sort by keys

Post by GeXus »

I have an array like this:

Code: Select all

Array
(
    [0] => Array
        (
            [uid] => 5151616
            [name] => Mike
            [pic] => pickurl.gif
            [is_user] => 0
        )

    [1] => Array
        (
            [uid] => 234656
            [name] => Bill
            [pic] => pickurl.gif
            [is_user] => 1
        )

    [2] => Array
        (
            [uid] => 2342651
            [name] => John
            [pic] => pickurl.gif
            [is_user] => 0
        )
)
I'd like to be able to sort by is_user descending, so everyone that is a user ('1') will be at the top FIRST, then a secondary accending sort by name...

Would anyone be able to help with this? I've checked out array_multisort, but I don't really get it...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

Post by GeXus »

Nice, thanks!
Post Reply