cancel
Showing results for 
Search instead for 
Did you mean: 

Sorting elements in template

andrepra
Champ in-the-making
Champ in-the-making
Exists any possibility to sort the sequence list of child nodes returning from the space.children freemarker function? I need to iterate the list sorted by child.name.


<#list space.children as child>

</#list>

Thanks
Andrew
1 REPLY 1

simon
Champ in-the-making
Champ in-the-making
You may find what you are looking for in the Freemarker documentation (http://freemarker.sourceforge.net/docs/ref_builtins_sequence.html😞

Returns the sequence sorted in ascending order. This will work only if all subvariables are strings, or if all subvariables are numbers, or, since FreeMarker 2.3.1, if all subvariables are date values (date, time, or date+time). If the subvariables are strings, it uses locale (language) specific lexical sorting (which is usually not case sensitive). For example:
      
<#assign ls = ["whale", "Barbara", "zeppelin", "aardvark", "beetroot"]?sort>
<#list ls as i>${i} </#list>