I have an array as below:
Array
(
[0] => Array
(
[id] => 2
[type] => comment
[batch] => Array
(
[0] => Array
(
[id] => T001
[datetime] => 2010-05-15 11:29:00
)
[1] => Array
(
[id] => T003
[datetime] => 2010-05-15 11:33:00
)
)
)
[1] => Array
(
[id] => 3
[type] => status
[batch] => Array
(
[0] => Array
(
[id] => T002
[datetime] => 2010-05-15 11:31:00
)
[1] => Array
(
[id] => T004
[datetime] => 2010-05-15 12:32:00
)
[2] => Array
(
[id] => T006
[datetime] => 2010-05-15 12:33:00
)
)
)
[2] => Array
(
[id] => 4
[type] => status
[batch] => Array
(
[0] => Array
(
[id] => T005
[datetime] => 2010-05-15 12:34:00
)
[1] => Array
(
[id] => T007
[datetime] => 2010-05-15 13:35:00
)
[2] => Array
(
[id] => T008
[datetime] => 2010-05-15 10:36:00
)
)
)
)
I would like to re-order the array by only the last datetime inside the sub array [batch]
the result should be like this:
Array
(
[0] => Array
(
[id] => 4
[type] => status
[batch] => Array
(
[0] => Array
(
[id] => T005
[datetime] => 2010-05-15 12:34:00
)
[1] => Array
(
[id] => T007
[datetime] => 2010-05-15 13:35:00
)
[2] => Array
(
[id] => T008
[datetime] => 2010-05-15 10:36:00
)
)
)
[1] => Array
(
[id] => 2
[type] => comment
[batch] => Array
(
[0] => Array
(
[id] => T001
[datetime] => 2010-05-15 11:29:00
)
[1] => Array
(
[id] => T003
[datetime] => 2010-05-15 11:33:00
)
)
)
[2] => Array
(
[id] => 3
[type] => status
[batch] => Array
(
[0] => Array
(
[id] => T002
[datetime] => 2010-05-15 11:31:00
)
[1] => Array
(
[id] => T004
[datetime] => 2010-05-15 12:32:00
)
[2] => Array
(
[id] => T006
[datetime] => 2010-05-15 12:33:00
)
)
)
)
Can I do it with "array_multisort"? Please suggest. Thank you very much!