Sort Multi dimensional array [duplicate]

99封情书 提交于 2019-12-13 08:32:50

问题


Possible Duplicate:
Sort a multi-dimensional array

How to sort the following array? array_multisort doesn't seem to do the job.

Array
(
    [2009] => Array
        (
            [name] => 2009
            [20100923WO2010107543A2] => 20100923WO2010107543A2
        )

    [2006] => Array
        (
            [name] => 2006
            [20080403US20080078500A1] => 20080403US20080078500A1
        )

    [1984] => Array
        (
            [name] => 1984
        )

)

Sorted Form

Array
(
    [1984] => Array
        (
            [name] => 1984
        )

    [2006] => Array
        (
            [name] => 2006
            [20080403US20080078500A1] => 20080403US20080078500A1
        )

    [2009] => Array
        (
            [name] => 2009
            [20100923WO2010107543A2] => 20100923WO2010107543A2
        )
)

回答1:


It seems you're trying to sort the array based on the keys. Use ksort().



来源:https://stackoverflow.com/questions/12006771/sort-multi-dimensional-array

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!