public Object getChild(Object parent, int index) {
    Collection c = null;

    if (parent instanceof IProject) {
      if (activeOnly()) c = CurrentProject.getTaskList().getActiveSubTasks(null, CurrentDate.get());
      else c = CurrentProject.getTaskList().getTopLevelTasks();
    } else {
      ITask t = (ITask) parent;
      if (activeOnly())
        c = CurrentProject.getTaskList().getActiveSubTasks(t.getID(), CurrentDate.get());
      else c = t.getSubTasks();
    }

    Object array[] = c.toArray();
    Arrays.sort(array, comparator);
    if (opposite) {
      return array[array.length - index - 1];
    }
    return array[index];
  }
        public int compare(Object o1, Object o2) {
          if (sorting_column == -1) return 0;
          if ((o1 instanceof ITask) == false) return 0;
          if ((o2 instanceof ITask) == false) return 0;

          ITask task1 = (ITask) o1;
          ITask task2 = (ITask) o2;

          // based on TaskTableModel.columnNames
          switch (sorting_column) {
            case 1:
              return task1.getText().compareTo(task2.getText());
            case 2:
              return task1.getStartDate().getDate().compareTo(task2.getStartDate().getDate());
            case 3:
              return task1.getEndDate().getDate().compareTo(task2.getEndDate().getDate());
            case 0: // task priority, same as 4
            case 4:
              return task1.getPriority() - task2.getPriority();
            case 5:
              return task1.getStatus(CurrentDate.get()) - task2.getStatus(CurrentDate.get());
            case 6:
              return task1.getProgress() - task2.getProgress();
          }

          return 0;
        }