Sorting a nested tree

View: New views
2 Messages — Rating Filter:   Alert me  

Sorting a nested tree

by rezkiyn :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

I am trying to sort a nested tree where I would like to sort on a child of the root element being the end date.

The structure is :

[{name=Education
  , data=Quality Management, type=text, options=[]
  , Level={name=Level, data=Bachelor, type=list, options=[]}
  , End_Date={name=End_Date, data=30/06/2000, type=text, options=[]}
}},
 {name=Education
   , data=Computer Science, type=text, options=[]
   , Level={name=Level, data=Bachelor, type=list, options=[]}
   , End_Date={name=End_Date, data=30/06/2000, type=text, options=[]}
}},
{name=Education
  , data=Business Economics, type=text, options=[]
  , Degree={name=Degree, data=MagnaCumLaude, type=list, options=[]}
  , Level={name=Level, data=Master, type=list, options=[]}
  , End_Date={name=End_Date, data=01/01/2008, type=text, options=[]}
}}]

The function I am calling is, but does not seem to work

#foreach($obj in $sorter.sort($Education.getSiblings().getChild("End_date"), "data"))
   $obj.getData()
#end

Can someone help me

Re: Sorting a nested tree

by Wxman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This appears to be a non-standard sort(), meaning that you are not
sorting alphabetically or numerically, and so you would need a custom
sort routine in your Java code.  If you perform this sort() in Java
(independent of Velocity), does it work?  If not, override your sort
method with your customizations for this data-type...

Mark

rezkiyn wrote:

> Hi all,
>
> I am trying to sort a nested tree where I would like to sort on a child of
> the root element being the end date.
>
> The structure is :
>
> [{name=Education
>   , data=Quality Management, type=text, options=[]
>   , Level={name=Level, data=Bachelor, type=list, options=[]}
>   , End_Date={name=End_Date, data=30/06/2000, type=text, options=[]}
> }},
>  {name=Education
>    , data=Computer Science, type=text, options=[]
>    , Level={name=Level, data=Bachelor, type=list, options=[]}
>    , End_Date={name=End_Date, data=30/06/2000, type=text, options=[]}
> }},
> {name=Education
>   , data=Business Economics, type=text, options=[]
>   , Degree={name=Degree, data=MagnaCumLaude, type=list, options=[]}
>   , Level={name=Level, data=Master, type=list, options=[]}
>   , End_Date={name=End_Date, data=01/01/2008, type=text, options=[]}
> }}]
>
> The function I am calling is, but does not seem to work
>
> #foreach($obj in $sorter.sort($Education.getSiblings().getChild("End_date"),
> "data"))
>    $obj.getData()
> #end
>
> Can someone help me
>
>  

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...