Specific complex array sorting
- by TheDeadMedic
Okay, a before;
Array (
'home' => array('order' => 1),
'about' => array(),
'folio' => array('order' => 2),
'folio/web' => array('order' => 2),
'folio/print' => array('order' => 1)
'contact' => array('order' => 2)
)
And a desired after;
Array (
'home' => array('order' => 1),
'contact' => array('order' => 2),
'folio' => array('order' => 2),
'folio/print' => array('order' => 1),
'folio/web' => array('order' => 2),
'about' => array()
)
I know, horrific (don't ask!)
See how the slash in the key indicates children, and how the order is nested accordingly? And items without orders are simply shifted to the bottom.
But also how multiple 'same level' items with the same order are merely sorted by key?