- 7.18. Opt_Xml_Scannable class
7.18.16. sort() - 7.18.15. replaceChild()
« Previous - 7.19. Opt_Xml_Text class
Next »
7.18.16. sort()
| Status | public |
|---|---|
| Reference | void sort(Array $prototypes) |
Changes the order of child nodes to follow the specified rules. It takes an array of tag names in the requested order. It must also include the element * to mark the location of the undefined nodes. An example:
$node->sort(Array( 'opt:foo', 'opt:bar', '*' ));
After the execution of the call above, in the first place, we will have opt:foo tags, later opt:bar and at last, the remaining tags. sort() is widely used in complex instructions to provide the correct order of important sub-tags. For example, opt:if uses the following code to make sure that opt:elseif and opt:else are located at the end of child list:
$node->sort(array('*' => 0, 'opt:elseif' => 1, 'opt:else' => 2));
If the element
*is not specified in$prototypes, the method generatesOpt_InvalidAttributes_Exception.
The method uses a stable sorting algorithm. It means that it keeps the order of equal nodes.
- 7.18.16. sort()
7.18. Opt_Xml_Scannable class - « Previous
7.18.15. replaceChild() - Next »
7.19. Opt_Xml_Text class