public void sortBy( String order ) {
        DefaultMutableTreeNode tmpNode = null;
        DefaultMutableTreeNode curNodeCopy = null;
        SortTreeModel treeModelTmp = null;
        DefaultMutableTreeNode rootTmp = new DefaultMutableTreeNode( rootNodeTxt );
        if ( order.equals( "name" ) ) {
            treeModelTmp = new SortTreeModel( rootTmp, new TreeStringComparatorName() );
            sortedByName = true;
        }
        else {
            treeModelTmp = new SortTreeModel( rootTmp, new TreeStringComparatorDate() );
            sortedByName = false;
        }
        sortByNameMenuItem.setEnabled( !sortedByName );
        sortByDateMenuItem.setEnabled( sortedByName );
        for ( @SuppressWarnings( "rawtypes" )
        Enumeration e = ( (DefaultMutableTreeNode) treeModel.getRoot() ).breadthFirstEnumeration(); e
                .hasMoreElements(); ) {
            DefaultMutableTreeNode curNode = (DefaultMutableTreeNode) e.nextElement();
            Object obj = curNode.getUserObject();
            if ( obj instanceof Item ) {
                Item currentItem = (Item) obj;
                if ( currentItem.isDir() )
                    curNodeCopy = new FolderNode( currentItem );
                else
                    curNodeCopy = new LeafNode( currentItem, ( (LeafNode) curNode ).getDownPerc(),
                            ( (LeafNode) curNode ).getStatus() );

                Object objPar = ( (DefaultMutableTreeNode) curNode.getParent() ).getUserObject();
                if ( objPar instanceof Item ) {
                    if ( ( tmpNode = getItemInTree( (Item) objPar, treeModelTmp ) ) != null ) {
                        treeModelTmp.insertNodeInto( curNodeCopy, tmpNode );
                    }
                }
                else {
                    treeModelTmp.insertNodeInto( curNodeCopy, rootTmp );
                }
            }
        }
        rootNode = rootTmp;
        treeModel = treeModelTmp;
        tree.setModel( treeModel );
    }