@Override public int compare( @NonNull EnvironmentFactoryInternal environmentFactory, @NonNull Feature match1, @NonNull Feature match2) { org.eclipse.ocl.pivot.Package p1 = PivotUtil.getContainingPackage(match1); org.eclipse.ocl.pivot.Package p2 = PivotUtil.getContainingPackage(match2); if (p1 == null) { return 0; } if (p2 == null) { return 0; } CompleteModel completeModel = environmentFactory.getCompleteModel(); CompletePackage s1 = completeModel.getCompletePackage(p1); CompletePackage s2 = completeModel.getCompletePackage(p2); if (s1 != s2) { return 0; } int i1 = s1.getIndex(p1); int i2 = s2.getIndex(p2); return i2 - i1; }