Hello everyone!, my problem is as follow: I'm working with several xml files that contain information about plants. I'm getting the contents from the files, then I pass it to an array and after to a DataObjectSet that I can access in my template. So far so good.
Now my problem is that I want to sort the information by an attribute that I defined in my xml files called sort. My array looks like this:
Array ( [0] => Array ( [name] => common [attributes] => Array ( [caption] => Common Name [sort] => 1 ) [text] => Concolor Fir [children] => Array ( ) ) [1] => Array ( [name] => latin [attributes] => Array ( [caption] => Latin Name [sort] => 2 ) [text] => Abies concolor [children] => Array ( ) )
And my DataObjectSet look like this:
DataObjectSet Object ( [items:protected] => Array ( [0] => ArrayData Object ( [array:protected] => Array ( [name] => common [attributes] => Array ( [caption] => Common Name [sort] => 1 ) [text] => Concolor Fir [children] => Array ( ) ) [iteratorPos:protected] => [iteratorTotalItems:protected] => [failover:protected] => [_object_cache:protected] => Array ( ) [_xml_cache:protected] => Array ( ) [_natural_cache:protected] => Array ( ) [customisedObj:protected] => [parent:protected] => [namedAs:protected] => [extension_instances:protected] => Array ( ) [class] => ) [1] => ArrayData Object ( [array:protected] => Array ( [name] => latin [attributes] => Array ( [caption] => Latin Name [sort] => 2 ) [text] => Abies concolor [children] => Array ( ) ) [iteratorPos:protected] => [iteratorTotalItems:protected] => [failover:protected] => [_object_cache:protected] => Array ( ) [_xml_cache:protected] => Array ( ) [_natural_cache:protected] => Array ( ) [customisedObj:protected] => [parent:protected] => [namedAs:protected] => [extension_instances:protected] => Array ( ) [class] => )
I have tried without any success to sort the array before doing DataObjectSet->push($array). I tried to use the usort function, but haven't figured it out so far. Now I'm wondering if there is a function that would allow me to sort the information in my DataObjectSet by the value in $attributes.sort. Or if I could build my own, how could I start with it?
Thanks;