PHP Associative array sort

Posted by Mithun on Stack Overflow See other posts from Stack Overflow or by Mithun
Published on 2010-06-02T12:21:34Z Indexed on 2010/06/02 16:54 UTC
Read the original article Hit count: 410

I have an array like one below. Currently it is sorted alphabetically by the OwnerNickName field. Now i want to brig the array entry with OwnerNickName 'My House' as the first entry of the array and rest sorted alphabetically by OwnerNickName. Any idea?

Array
(
    [0318B69D-5DEB-11DF-9D7E-0026B9481364] => Array
        (
            [OwnerNickName] => andy
            [Rooms] => Array
                (
                    [0] => Array
                        (
                            [Label] => Living Room
                            [RoomKey] => FC795A73-695E-11DF-9D7E-0026B9481364
                        )

                )

        )

    [286C29DE-A9BE-102D-9C16-00163EEDFCFC] => Array
        (
            [OwnerNickName] => anton
            [Rooms] => Array
                (
                    [0] => Array
                        (
                            [Label] => KidsRoom
                            [RoomKey] => E79D7991-64DC-11DF-9D7E-0026B9481364
                        )

                    [1] => Array
                        (
                            [Label] => Basement
                            [RoomKey] => CC12C0C4-68AA-11DF-9D7E-0026B9481364
                        )

                    [2] => Array
                        (
                            [Label] => Family Room
                            [RoomKey] => 67A280D4-64D9-11DF-9D7E-0026B9481364
                        )

                )

        )

    [8BE18F84-AC22-102D-9C16-00163EEDFCFC] => Array
        (
            [OwnerNickName] => mike
            [Rooms] => Array
                (
                    [0] => Array
                        (
                            [Label] => Family Room
                            [RoomKey] => 1C6AFB39-6835-11DF-9D7E-0026B9481364
                        )

                )

        )

    [29B455DE-A9BC-102D-9C16-00163EEDFCFC] => Array
        (
            [OwnerNickName] => My House
            [Rooms] => Array
                (
                    [0] => Array
                        (
                            [Label] => Basement
                            [RoomKey] => 61ECFAB2-6376-11DF-9D7E-0026B9481364
                        )

                    [1] => Array
                        (
                            [Label] => Rec Room
                            [RoomKey] => 52B8B781-6376-11DF-9D7E-0026B9481364
                        )

                    [2] => Array
                        (
                            [Label] => Deck
                            [RoomKey] => FFEB4102-64DE-11DF-9D7E-0026B9481364
                        )

                    [3] => Array
                        (
                            [Label] => My Room2
                            [RoomKey] => 112473E4-64DF-11DF-9D7E-0026B9481364
                        )

                    [4] => Array
                        (
                            [Label] => Bar Room
                            [RoomKey] => F82C47A8-64DE-11DF-9D7E-0026B9481364
                        )

                )

        )

)

© Stack Overflow or respective owner

Related posts about php

Related posts about array