Bug 60101 Sort by parent path should take method name into account
build i0420:0800 - I do a Java Search and sort the results by Parent Path - I believe the secondary sort consideration should be the method name - this would make the results sorted alphabetically Here are the currently results. Note I removed part of the package name to make the list clearer. (#addChild is out of order alphabetically) I'm not sure what order its listed in...#addChild is at the beginning of the java file so its not by order of appearance in the file. preferences.EclipsePreferences.childrenNames() preferences.EclipsePreferences.getChild(String) (2 matches) preferences.EclipsePreferences.getChildren() (2 matches) preferences.EclipsePreferences.removeNode(IEclipsePreferences) (4 matches) preferences.EclipsePreferences.addChild(String, IEclipsePreferences) (3 matches) preferences.RootPreferences.getChild(String) (2 matches)
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/PathSorter.java
public int compare(Viewer viewer, Object e1, Object e2) {
		IPath path1= getPath(e1);
		IPath path2=getPath(e2);
		return compare(path1, path2);
	}
	
	/**
	 * @param e1
	 * @return
	 */
	private IPath getPath(Object element) {
		if (element instanceof IJavaElement)
			return ((IJavaElement)element).getPath();
		if (element instanceof IResource)
			return ((IResource)element).getFullPath();
		return new Path(""); 
	}
	protected int compare(IPath path1, IPath path2) {
		int segmentCount= Math.min(path1.segmentCount(), path2.segmentCount());
		for (int i= 0; i < segmentCount; i++) {
			int value= collator.compare(path1.segment(i), path2.segment(i));
			if (value != 0)
				return value;
		}
		return path1.segmentCount() - path2.segmentCount();
	}
}