Ejemplo n.º 1
0
 /**
  * Sorts INode's children by key.
  *
  *
  * @param INode $node the root node
  * @return void
  */
 protected function sortChildren(INode $node)
 {
     $children = $node->getChildren();
     $node->removeChildren();
     foreach ($this->sortNodes($children) as $index => $child) {
         $this->sortChildren($child);
         // recursion
         $node->addChild($child, $index);
     }
 }
 /**
  * Sorts INode's children by key.
  *
  *
  * @param INode $node the root node
  * @return void
  */
 protected function sortChildren(INode $node)
 {
     if ($this->sorting !== NULL) {
         $children = $node->getChildren();
         $node->removeChildren();
         $sortedNodes = call_user_func($this->sorting, $children);
         foreach ($sortedNodes as $index => $child) {
             $this->sortChildren($child);
             // recursion
             $node->addChild($child, $index);
         }
     }
     return $this;
 }