=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnitTree.vm' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnitTree.vm 2011-07-21 15:16:53 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonOrganisationUnitTree.vm 2011-07-24 15:07:45 +0000 @@ -6,7 +6,8 @@ "hasChildren": #if( $organisationUnit.children.size() > 0 )true,#{else}false#end #if( $organisationUnit.children.size() > 0 ) "children": [ - #foreach ( $child in $organisationUnit.children ) + #set( $children = $sorter.sortOrganisationUnitSet( $organisationUnit.children ) ) + #foreach ( $child in $children ) #expandOrganisationUnit( $child )#if( $velocityCount < $organisationUnit.children.size() ),#end #end ] === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitTreeAction.java' --- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitTreeAction.java 2011-07-21 15:16:53 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitTreeAction.java 2011-07-24 15:07:45 +0000 @@ -31,6 +31,9 @@ import java.util.Collections; import java.util.Comparator; import java.util.List; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitService; @@ -85,6 +88,22 @@ return organisationUnits; } + public class SetSorter + { + public Set sortOrganisationUnitSet( Set organisationUnits ) + { + SortedSet sortedSet = new TreeSet( organisationUnitComparator ); + sortedSet.addAll( organisationUnits ); + + return sortedSet; + } + } + + public SetSorter getSorter() + { + return new SetSorter(); + } + // ------------------------------------------------------------------------- // Action implementation // -------------------------------------------------------------------------