按字母顺序按值对多维数组进行排序

时间:2013-03-13 17:37:02

标签: php arrays multidimensional-array

我需要按字母顺序对数组进行排序,因此结果应该是这样的:

Inn Zoo
Leo Ann
Leo Zes
Sun Yog

我查看了所有这些示例,但无法应用于我的数组(旧问题):


Array
(
    [1] => Array
        (
            [Inn] => Array
                (
                    [Zoo] => Inn Zoo
                )

        )

    [2] => Array
        (
            [Sun] => Array
                (
                    [Yog] => Sun Yog
                )

        )

    [3] => Array
        (
            [Leo] => Array
                (
                    [Zes] => Leo Zes
                )

        )
    [4] => Array
        (
            [Leo] => Array
                (
                    [Ann] => Leo Ann
                )

        )
)

1 个答案:

答案 0 :(得分:-1)

array
(
    [0] => Inn|Zoo|Inn Zoo
    [1] => Sunn|Yog|Sun Yog
    [2] => Leo|Zes|Leo Ann
    [3] => Leo|Ann|Leo Zes
)

asort($list);

array
(
    [0] => Inn|Zoo|Inn Zoo
    [3] => Leo|Ann|Leo Zes
    [2] => Leo|Zes|Leo Ann
    [1] => Sunn|Yog|Sun Yog
)