问题
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