/** * orderByEntity * * @access public * @return void */ public function orderByEntity($entity = 'entity', $attr = 'name') { $tags = $this->xpath('//application/' . $entity); $array = array(); foreach ($tags as $key => $tag) { $array[(string) $tag[$attr]] = $key; } ksort($array); $xml = new XMLElement(XML_HEADER . '<' . $this->getName() . '/>'); foreach ($this->attributes() as $k => $v) { $xml->addAttribute($k, $v); } foreach ($this->children() as $name => $child) { if ($name != $entity) { $xml->addNode($child); } } foreach ($array as $key => $value) { $xml->addNode($tags[$value]); } return $xml; }