XML sorting in PHP

addedaasterne

New Member
Hi I want to sort an XML document - I do it like this:\[code\]public function xsort(&$nodes, $child_name, $order=SORT_ASC){ $sort_proxy = array(); foreach($nodes as $k => $node) { $sort_proxy[$k] = (string) $node->$child_name; } array_multisort($sort_proxy, $order, $nodes);}\[/code\]And I get sorted array in \[code\]$nodes\[/code\] variable. In code it is used in this way:\[code\]$this->xsort($nodes, 'kategoria_6', SORT_DESC);\[/code\]When I do print_r($nodes); I get sorted view\[code\]SimpleXMLElement Object ( [kategoria_6] => kat4 [opis_6] => opis4
code\]Does anyone know why it is saving unsorted
 
Back
Top