Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting Associative Array - multiple keys

Status
Not open for further replies.

cmayo

MIS
Apr 23, 2001
159
US
Does anyone know of an arry sort that'll let me sort an associative array on multiple keys at multiple levels? I have an array of events, and each event (below) contains multiple keys and sub-arrays. I need to sort the entire event array based on the sorts shown below.

I imagine there are some pre-written routines or classes that'd let me do something like this, but I don't seem to be able to turn anything up.

Code:
EVENT Array
(
    [84815] => Array [b](84815 is event ID)[/b]
        (
            [date_time] => 2006-02-22 19:30:00 [b]<- FOURTH SORT ASC[/b]
            [date] => 2006-02-22
            [time] => 19:30:00
            [status] => 6
            [status_text] => Complete
            [away] => Array
                (
                    [id] => 716
                    [name] => Molina
                    [score] => 3
                    [district_id] => 172
                    [district_name] => 9-5A
                    [district_dist] => 9
                    [district_class] => 5A
                )

            [home] => Array
                (
                    [id] => 47
                    [name] => W.T. White
                    [score] => 4
                    [district_id] => 172
                    [district_name] => 9-5A
                    [district_dist] => 9 [b]<- SECOND SORT - DESC[/b]
                    [district_class] => 5A [b]<- THIRD SORT - ASC[/b]
                )

            [site] => 1824
            [site_name] => Forester
            [winner] => 
            [type] => 10 [b]<- FIRST SORT - CUSTOM (10,4,27,etc.)[/b]
            [type_description] => District
        )
 
uasort() for associative arrays so you can be sure to maintain index association, no?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top