排序多维数组

时间:2012-08-17 13:28:30

标签: php arrays sorting dimension

  

可能重复:
  Sort a multi-dimensional array

如何对以下数组进行排序? array_multisort似乎没有完成这项工作。

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

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

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

)

排序表格

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

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

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

1 个答案:

答案 0 :(得分:1)

您似乎正在尝试根据键对数组进行排序。使用ksort()