protected int compareFolders ( final Entry e1 , final Entry e2 ) { final boolean f1 = e1 instanceof Folder ; final boolean f2 = e2 instanceof Folder ; if ( f1 && ! f2 ) { return - 1 ; } else if ( ! f1 && f2 ) { return 1 ; } else { return 0 ; } }
Folders are always greater than non - Folders if they are both Folders or both not Folders they are equal .