code: public void sort(ChildTaskContainer container)
     {
        // Do we have any tasks?
        List<Task> tasks = container.getChildTasks();
        if (!tasks.isEmpty())
        {
           for (Task task : tasks)
           {
              //
              // Sort child activities
              //
              sort(task);
  
              //
              // Sort Order:
              // 1. Activities come first
              // 2. WBS come last
              // 3. Activities ordered by activity ID
              // 4. WBS ordered by ID
              //
              Collections.sort(tasks, new Comparator<Task>()
              {
                 @Override public int compare(Task t1, Task t2)
                 {
                    boolean t1IsWbs = m_wbsTasks.contains(t1);
                    boolean t2IsWbs = m_wbsTasks.contains(t2);
  
                    // Both are WBS
                    if (t1IsWbs && t2IsWbs)
                    {
                       return t1.getID().compareTo(t2.getID());
                    }
  
                    // Both are activities
                    if (!t1IsWbs && !t2IsWbs)
                    {
                       String activityID1 = (String) t1.getCurrentValue(m_activityIDField);
                       String activityID2 = (String) t2.getCurrentValue(m_activityIDField);
  
                       if (activityID1 == null || activityID2 == null)
                       {
                          return (activityID1 == null && activityID2 == null ? 0 : (activityID1 == null ? 1 : -1));
                       }
  
                       return activityID1.compareTo(activityID2);
                    }
  
                    // One activity one WBS
                    return t1IsWbs ? 1 : -1;
                 }
              });
           }
        }
     }
docs: Recursively sort the supplied child tasks.
  
  @param container child tasks