Program: 129108
Project: 129108
Buggy source:
private void addSorter(final TreeViewer viewer2){
  final Tree table=viewer2.getTree();
  Listener sortListener=new Listener(){
    private int direction=1;
    public void handleEvent(    Event e){
      final TreeColumn column=(TreeColumn)e.widget;
      if (column == table.getSortColumn()) {
        direction=-direction;
      }
      if (direction == 1) {
        table.setSortDirection(SWT.UP);
      }
 else {
        table.setSortDirection(SWT.DOWN);
      }
      table.setSortColumn(column);
      viewer2.setSorter(new ViewerSorter(){
        int index=0;
        @Override public void sort(        Viewer viewer,        Object[] elements){
          boolean found=false;
          for (index=0; index < table.getColumns().length; index++) {
            if (table.getColumn(index) == table.getSortColumn()) {
              found=true;
              break;
            }
          }
          if (!found) {
            index=0;
          }
          super.sort(viewer,elements);
        }
        @Override public int compare(        Viewer viewer,        Object e1,        Object e2){
          ITableLabelProvider labelProvider=(ITableLabelProvider)viewer2.getLabelProvider();
          String columnText=labelProvider.getColumnText(e1,index) != null ? labelProvider.getColumnText(e1,index) : "String_Node_Str";
          String columnText2=labelProvider.getColumnText(e2,index) != null ? labelProvider.getColumnText(e2,index) : "String_Node_Str";
          return getComparator().compare(columnText,columnText2) * direction;
        }
      }
);
    }
  }
;
  table.getColumn(0).addListener(SWT.Selection,sortListener);
  if (getContexts().size() > 0) {
    for (int i=0; i < getContexts().size(); i++) {
      table.getColumn(i + 1).addListener(SWT.Selection,sortListener);
    }
  }
  table.setSortColumn(table.getColumn(0));
  table.setSortDirection(SWT.UP);
}

Fixed version (ground truth):
private void addSorter(final TreeViewer viewer2){
  final Tree table=viewer2.getTree();
  Listener sortListener=new Listener(){
    private int direction=1;
    @Override public void handleEvent(    Event e){
      final TreeColumn column=(TreeColumn)e.widget;
      if (column == table.getSortColumn()) {
        direction=-direction;
      }
      if (direction == 1) {
        table.setSortDirection(SWT.UP);
      }
 else {
        table.setSortDirection(SWT.DOWN);
      }
      table.setSortColumn(column);
      viewer2.setSorter(new ViewerSorter(){
        int index=0;
        @Override public void sort(        Viewer viewer,        Object[] elements){
          boolean found=false;
          for (index=0; index < table.getColumns().length; index++) {
            if (table.getColumn(index) == table.getSortColumn()) {
              found=true;
              break;
            }
          }
          if (!found) {
            index=0;
          }
          super.sort(viewer,elements);
        }
        @Override public int compare(        Viewer viewer,        Object e1,        Object e2){
          ITableLabelProvider labelProvider=(ITableLabelProvider)viewer2.getLabelProvider();
          String columnText=labelProvider.getColumnText(e1,index) != null ? labelProvider.getColumnText(e1,index) : "String_Node_Str";
          String columnText2=labelProvider.getColumnText(e2,index) != null ? labelProvider.getColumnText(e2,index) : "String_Node_Str";
          return getComparator().compare(columnText,columnText2) * direction;
        }
      }
);
    }
  }
;
  table.getColumn(0).addListener(SWT.Selection,sortListener);
  if (getContexts().size() > 0) {
    for (int i=0; i < getContexts().size(); i++) {
      table.getColumn(i + 1).addListener(SWT.Selection,sortListener);
    }
  }
  table.setSortColumn(table.getColumn(0));
  table.setSortDirection(SWT.UP);
}