I have the below array that has been generated from wordpress using get_children(). The problem is that it can't seem to order the output by the menu order used in wordpress.
So the bellow array needs sorting by the inner value of the key [menu_order]. I've tried a number of different ways using usort etc, but can't seem to get it to work.
Array
(
[40] => WP_Post Object
(
[ID] => 40
[post_author] => 1
[post_date] => 2016-09-03 19:31:25
[post_date_gmt] => 2016-09-03 19:31:25
[post_content] => test 2
[post_title] => Test 2
[post_excerpt] =>
[post_status] => publish
[comment_status] => closed
[ping_status] => closed
[post_password] =>
[post_name] => test-2
[to_ping] =>
[pinged] =>
[post_modified] => 2016-09-03 19:56:04
[post_modified_gmt] => 2016-09-03 19:56:04
[post_content_filtered] =>
[post_parent] => 2
[guid] => http://example.com/2
[menu_order] => 2
[post_type] => page
[post_mime_type] =>
[comment_count] => 0
[filter] => raw
)
[38] => WP_Post Object
(
[ID] => 38
[post_author] => 1
[post_date] => 2016-09-03 19:23:18
[post_date_gmt] => 2016-09-03 19:23:18
[post_content] => test 1
[post_title] => Test 1
[post_excerpt] =>
[post_status] => publish
[comment_status] => closed
[ping_status] => closed
[post_password] =>
[post_name] => test-1
[to_ping] =>
[pinged] =>
[post_modified] => 2016-09-03 19:51:17
[post_modified_gmt] => 2016-09-03 19:51:17
[post_content_filtered] =>
[post_parent] => 2
[guid] => http://example.com/1
[menu_order] => 1
[post_type] => page
[post_mime_type] =>
[comment_count] => 0
[filter] => raw
)
)
usortand provide a custom function (preferably a closure) which compares the element.