jh: Custom Category sorting improvement - show in lib view   bug 171854
diff --git a/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/dialogs/ContentElementsOrderDialog.java b/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/dialogs/ContentElementsOrderDialog.java
index 31c0a60..8ce8b48 100755
--- a/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/dialogs/ContentElementsOrderDialog.java
+++ b/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/dialogs/ContentElementsOrderDialog.java
@@ -19,14 +19,14 @@
 import org.eclipse.epf.authoring.ui.AuthoringUIResources;
 import org.eclipse.epf.authoring.ui.AuthoringUIText;
 import org.eclipse.epf.authoring.ui.providers.VariabilityElementLabelProvider;
-import org.eclipse.epf.library.LibraryResources;
+import org.eclipse.epf.library.edit.LibraryEditResources;
 import org.eclipse.epf.library.edit.TngAdapterFactory;
 import org.eclipse.epf.library.edit.command.IActionManager;
 import org.eclipse.epf.library.edit.command.MoveInCategoryCommand;
+import org.eclipse.epf.library.edit.util.CategorySortHelper;
 import org.eclipse.epf.library.edit.util.ContentElementOrderList;
 import org.eclipse.epf.library.edit.util.ModelStructure;
 import org.eclipse.epf.library.edit.util.TngUtil;
-import org.eclipse.epf.library.util.CategorySortHelper;
 import org.eclipse.epf.uma.ContentElement;
 import org.eclipse.epf.uma.CustomCategory;
 import org.eclipse.epf.uma.MethodElement;
@@ -183,7 +183,7 @@
 		ctrl_up.setEnabled(false);
 		ctrl_down.setEnabled(false);
 
-		createLabel(orderButtonPane, LibraryResources.SortType_Label, 1);
+		createLabel(orderButtonPane, LibraryEditResources.SortType_Label, 1);
 		Combo ctrl_sort = new Combo(orderButtonPane, SWT.SINGLE | SWT.FLAT | SWT.READ_ONLY);
 		viewer_sort = new ComboViewer(ctrl_sort);
 		viewer_sort.setContentProvider(contentProviderSort);
diff --git a/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/forms/AssociationFormPage.java b/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/forms/AssociationFormPage.java
index 7308db2..dcb6187 100755
--- a/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/forms/AssociationFormPage.java
+++ b/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/forms/AssociationFormPage.java
@@ -22,13 +22,14 @@
 import org.eclipse.epf.authoring.ui.editors.MethodElementEditor;
 import org.eclipse.epf.authoring.ui.util.EditorsContextHelper;
 import org.eclipse.epf.authoring.ui.util.UIHelper;
-import org.eclipse.epf.library.LibraryResources;
+import org.eclipse.epf.authoring.ui.views.LibraryView;
 import org.eclipse.epf.library.edit.IFilter;
+import org.eclipse.epf.library.edit.LibraryEditResources;
 import org.eclipse.epf.library.edit.TngAdapterFactory;
 import org.eclipse.epf.library.edit.command.IActionManager;
+import org.eclipse.epf.library.edit.util.CategorySortHelper;
 import org.eclipse.epf.library.edit.util.TngUtil;
 import org.eclipse.epf.library.ui.LibraryUIText;
-import org.eclipse.epf.library.util.CategorySortHelper;
 import org.eclipse.epf.library.util.LibraryManager;
 import org.eclipse.epf.uma.ContentElement;
 import org.eclipse.epf.uma.MethodElement;
@@ -376,7 +377,7 @@
 					ctrl_up1 = createButton(toolkit, pane2, UP_BUTTON);
 					ctrl_down1 = createButton(toolkit, pane2, DOWN_BUTTON);
 					ctrl_ordering = createButton(toolkit, pane2, ORDER_BUTTON);
-					Combo ctrl_sort1 = createComboWithLabel(toolkit, pane2, LibraryResources.SortType_Label);
+					Combo ctrl_sort1 = createComboWithLabel(toolkit, pane2, LibraryEditResources.SortType_Label);
 					viewer_sort1 = new ComboViewer(ctrl_sort1);
 					viewer_sort1.setContentProvider(contentProviderSort);
 					viewer_sort1.setLabelProvider(labelProviderSort);
@@ -979,6 +980,8 @@
 									.getMethodElementProperty_Value(),
 									sortType, -1);
 					}
+					LibraryView.getView().refreshViews();
+
 					if (viewer_selected.getTable().getSelectionIndex() > 0
 							&& !TngUtil.isLocked(contentElement) &&
 							CategorySortHelper.isManualCategorySort(contentElement)) {
diff --git a/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/forms/CustomCategoryAssignPage.java b/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/forms/CustomCategoryAssignPage.java
index 73f8a86..cc668a1 100755
--- a/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/forms/CustomCategoryAssignPage.java
+++ b/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/forms/CustomCategoryAssignPage.java
@@ -30,13 +30,13 @@
 import org.eclipse.epf.library.edit.TngAdapterFactory;
 import org.eclipse.epf.library.edit.command.MoveInCategoryCommand;
 import org.eclipse.epf.library.edit.itemsfilter.FilterConstants;
+import org.eclipse.epf.library.edit.util.CategorySortHelper;
 import org.eclipse.epf.library.edit.util.Comparators;
 import org.eclipse.epf.library.edit.util.ContentElementOrderList;
 import org.eclipse.epf.library.edit.util.ModelStructure;
 import org.eclipse.epf.library.edit.util.TngUtil;
 import org.eclipse.epf.library.edit.validation.DependencyChecker;
 import org.eclipse.epf.library.ui.LibraryUIManager;
-import org.eclipse.epf.library.util.CategorySortHelper;
 import org.eclipse.epf.library.util.LibraryManager;
 import org.eclipse.epf.uma.Activity;
 import org.eclipse.epf.uma.ContentElement;
diff --git a/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/views/LibraryView.java b/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/views/LibraryView.java
index a3caff5..087325b 100755
--- a/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/views/LibraryView.java
+++ b/plugins/org.eclipse.epf.authoring.ui/src/org/eclipse/epf/authoring/ui/views/LibraryView.java
@@ -1290,7 +1290,7 @@
 	 */
 	public void createContextMenuFor(final StructuredViewer viewer) {
 		super.createContextMenuFor(viewer);
-		int dndOperations = DND.DROP_MOVE | DND.DROP_COPY;
+		int dndOperations = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK;
 		Transfer[] transfers = new Transfer[] { HTMLTransfer.getInstance(),
 				TextTransfer.getInstance(), LocalTransfer.getInstance() };
 		viewer.addDragSupport(dndOperations, transfers,
diff --git a/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/LibraryEditResources.java b/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/LibraryEditResources.java
index a143cb9..eb36d18 100755
--- a/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/LibraryEditResources.java
+++ b/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/LibraryEditResources.java
@@ -383,6 +383,16 @@
 	
 	public static String CreateProcessComponentCommand_Message;
 
+	public static String SortType_Label;
+
+	public static String SortType_Manual;
+
+	public static String SortType_Alphabetic;
+	
+	public static String SortType_ReverseAlphabetic;
+	
+	public static String SortType_MethodType;
+
 	static {
 		NLS.initializeMessages(BUNDLE_NAME, LibraryEditResources.class);
 	}
diff --git a/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/PresentationContext.java b/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/PresentationContext.java
index c7ec46e..823f9b0 100755
--- a/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/PresentationContext.java
+++ b/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/PresentationContext.java
@@ -30,6 +30,9 @@
 
 	private boolean showPresentationNames = false;
 	private Comparator comparator = Comparators.DEFAULT_COMPARATOR;
+	private Comparator reverseComparator = Comparators.REVERSE_DEFAULT_COMPARATOR;
+	private Comparator methodElementTypeComparator = Comparators.METHOD_TYPE_COMPARATOR;
+	
 	
 	private Comparator guidanceTypeComparator = new TypeComparator() {
 		/* (non-Javadoc)
@@ -50,26 +53,6 @@
 			return -1;
 		}
 	};
-	
-	private Comparator methodElementTypeComparator = new TypeComparator() {
-		/* (non-Javadoc)
-		 * @see org.eclipse.epf.library.edit.util.Comparators.TypeComparator#getDefaultComparator()
-		 */
-		protected Comparator getDefaultComparator() {
-			return comparator;
-		}
-
-		protected int getOrderId(Object obj) {
-			if (obj instanceof MethodElement) {
-				int id = ((MethodElement) obj).eClass().getClassifierID();
-				if (id == UmaPackage.TERM_DEFINITION) {
-					id = Integer.MAX_VALUE;
-				}
-				return id;
-			}
-			return -1;
-		}
-	};
 
 	private Comparator processPackageComparator = new TypeComparator() {
 		/* (non-Javadoc)
@@ -102,12 +85,18 @@
 	public void setShowPresentationNames(boolean showPresentationNames) {
 		this.showPresentationNames = showPresentationNames;
 		comparator = showPresentationNames ? Comparators.PRESENTATION_NAME_COMPARATOR : Comparators.DEFAULT_COMPARATOR;
+		reverseComparator = showPresentationNames ? Comparators.REVERSE_PRESENTATION_NAME_COMPARATOR : Comparators.REVERSE_DEFAULT_COMPARATOR;
+		methodElementTypeComparator = showPresentationNames ? Comparators.METHOD_TYPE_PRES_NAME_COMPARATOR : Comparators.METHOD_TYPE_COMPARATOR;
 	}
 
 	public Comparator getComparator() {
 		return comparator;
 	}
 
+	public Comparator getReverseComparator() {
+		return reverseComparator;
+	}
+
 	public Comparator getGuidanceTypeComparator() {
 		return guidanceTypeComparator;
 	}
@@ -119,4 +108,17 @@
 	public Comparator getMethodElementTypeComparator() {
 		return methodElementTypeComparator;
 	}
+	
+	public Comparator getPresNameComparator() {
+		return Comparators.PRESENTATION_NAME_COMPARATOR;
+	}
+
+	public Comparator getPresNameReverseComparator() {
+		return Comparators.REVERSE_PRESENTATION_NAME_COMPARATOR;
+	}
+	
+	public Comparator getPresNameMethodElementTypeComparator() {
+		return Comparators.METHOD_TYPE_PRES_NAME_COMPARATOR;
+	}
+
 }
diff --git a/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/Resources.properties b/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/Resources.properties
index fbf4cbe..a0ca736 100755
--- a/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/Resources.properties
+++ b/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/Resources.properties
@@ -227,3 +227,10 @@
 variability_element_circular_loop_error_msg=Circular dependency loop detected ... 
 replacing_ancestor_error_msg=Replacing an ancestor error is detected.
 cannot_copy_or_extend_delivery_process=Cannot copy or extend a delivery process or any of its activities.
+
+# Sort options
+SortType_Label=Sort Type:
+SortType_Manual=Manual
+SortType_Alphabetic=Alphabetic
+SortType_ReverseAlphabetic=Reverse Alphabetic
+SortType_MethodType=Method Type
diff --git a/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/category/CustomCategoryItemProvider.java b/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/category/CustomCategoryItemProvider.java
index 9833a43..4adbed7 100755
--- a/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/category/CustomCategoryItemProvider.java
+++ b/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/category/CustomCategoryItemProvider.java
@@ -32,14 +32,13 @@
 import org.eclipse.emf.edit.command.CopyCommand.Helper;
 import org.eclipse.emf.edit.domain.EditingDomain;
 import org.eclipse.emf.edit.provider.INotifyChangedListener;
-import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
 import org.eclipse.emf.edit.provider.ViewerNotification;
 import org.eclipse.epf.library.edit.IDefaultNameSetter;
 import org.eclipse.epf.library.edit.ILibraryItemProvider;
 import org.eclipse.epf.library.edit.LibraryEditPlugin;
 import org.eclipse.epf.library.edit.PresentationContext;
 import org.eclipse.epf.library.edit.command.MethodElementAddCommand;
-import org.eclipse.epf.library.edit.internal.TngAdapterFactoryImpl;
+import org.eclipse.epf.library.edit.util.CategorySortHelper;
 import org.eclipse.epf.library.edit.util.LibraryEditConstants;
 import org.eclipse.epf.library.edit.util.MethodElementUtil;
 import org.eclipse.epf.library.edit.util.ModelStructure;
@@ -55,7 +54,6 @@
 import org.eclipse.epf.uma.edit.command.MethodElementCreateCopyCommand;
 import org.eclipse.epf.uma.edit.command.MethodElementInitializeCopyCommand;
 import org.eclipse.epf.uma.util.AssociationHelper;
-import org.eclipse.jface.viewers.ITreeContentProvider;
 
 /**
  * The item provider adapter for a custom category.
@@ -208,6 +206,9 @@
 				}
 			}
 			break;
+		case UmaPackage.METHOD_ELEMENT__METHOD_ELEMENT_PROPERTY:
+			fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false));
+			break;
 		// case UmaPackage.CUSTOM_CATEGORY__SUB_CATEGORIES:
 		case UmaPackage.CUSTOM_CATEGORY__CATEGORIZED_ELEMENTS:
 			pkg = (ContentPackage) ((EObject) notification.getNotifier())
@@ -491,6 +492,9 @@
 			sortList.addAll(col);
 			Collections.sort(sortList, PresentationContext.INSTANCE.getComparator());
 			return sortList;
+		} else if (object instanceof MethodElement) {
+			List sortList = CategorySortHelper.sortCategoryElements((MethodElement)object, col.toArray());
+			return sortList;
 		}
 		return col;
 	}
diff --git a/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/util/CategorySortHelper.java b/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/util/CategorySortHelper.java
similarity index 74%
rename from plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/util/CategorySortHelper.java
rename to plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/util/CategorySortHelper.java
index e3fac2f..51e00cd 100755
--- a/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/util/CategorySortHelper.java
+++ b/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/util/CategorySortHelper.java
@@ -8,17 +8,17 @@
 // Contributors:
 // IBM Corporation - initial implementation
 //------------------------------------------------------------------------------
-package org.eclipse.epf.library.util;
+package org.eclipse.epf.library.edit.util;
 
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
+import java.util.Comparator;
 import java.util.Iterator;
 import java.util.List;
 
-import org.eclipse.epf.library.LibraryResources;
+import org.eclipse.epf.library.edit.LibraryEditResources;
 import org.eclipse.epf.library.edit.PresentationContext;
-import org.eclipse.epf.library.edit.util.Comparators;
 import org.eclipse.epf.uma.MethodElement;
 import org.eclipse.epf.uma.MethodElementProperty;
 import org.eclipse.epf.uma.UmaFactory;
@@ -104,39 +104,59 @@
 
 	public static String getSortTypeDisplayName(String sortType) {
 		if (V_CATEGORY_ELEMENTS__SORT_TYPE_ALPHA.equals(sortType)) {
-			return LibraryResources.SortType_Alphabetic;
+			return LibraryEditResources.SortType_Alphabetic;
 		}
 		if (V_CATEGORY_ELEMENTS__SORT_TYPE_REVERSE_ALPHA.equals(sortType)) {
-			return LibraryResources.SortType_ReverseAlphabetic;
+			return LibraryEditResources.SortType_ReverseAlphabetic;
 		}
 		if (V_CATEGORY_ELEMENTS__SORT_TYPE_METHOD_TYPE.equals(sortType)) {
-			return LibraryResources.SortType_MethodType;
+			return LibraryEditResources.SortType_MethodType;
 		}
 		if (V_CATEGORY_ELEMENTS__SORT_TYPE_MANUAL.equals(sortType)) {
-			return LibraryResources.SortType_Manual;
+			return LibraryEditResources.SortType_Manual;
 		}
 		return "";
 	}
+	
+	/**
+	 * Returns a sorted category element list based on the category's sort type
+	 * Respects the Name/PresName toggle
+	 * @param element 
+	 * @param elements array to sort
+	 * @return
+	 */
+	public static List<Object> sortCategoryElements(MethodElement element, Object[] elements) {
+		return sortCategoryElements(element, elements, false);
+	}
 
 	/**
 	 * Returns a sorted category element list based on the category's sort type
 	 * @param element 
 	 * @param elements array to sort
+	 * @param forcePresNameSort true to always sort by presName. false will respect the toggle
 	 * @return
 	 */
-	public static List<Object> sortCategoryElements(MethodElement element, Object[] elements) {
+	public static List<Object> sortCategoryElements(MethodElement element, Object[] elements, boolean forcePresNameSort) {
 		List<Object> returnList = new ArrayList<Object>(Arrays.<Object>asList(elements));
 		String sortType = getCategorySortValue(element);
 		if (V_CATEGORY_ELEMENTS__SORT_TYPE_MANUAL.equals(sortType)) {
 			return returnList;
 		} else if (V_CATEGORY_ELEMENTS__SORT_TYPE_ALPHA.equals(sortType)) {
-			Collections.<Object>sort(returnList, Comparators.DEFAULT_COMPARATOR);
+			Comparator comparator = PresentationContext.INSTANCE.getComparator();
+			if (forcePresNameSort)
+				comparator = PresentationContext.INSTANCE.getPresNameComparator();
+			Collections.<Object>sort(returnList, comparator);
 		} else if (V_CATEGORY_ELEMENTS__SORT_TYPE_REVERSE_ALPHA.equals(sortType)) {
-			Collections.<Object>sort(returnList, Comparators.REVERSE_NAME_COMPARATOR);
+			Comparator comparator = PresentationContext.INSTANCE.getReverseComparator();
+			if (forcePresNameSort)
+				comparator = PresentationContext.INSTANCE.getPresNameReverseComparator();
+			Collections.<Object>sort(returnList, comparator);
 		} else if (V_CATEGORY_ELEMENTS__SORT_TYPE_METHOD_TYPE.equals(sortType)) {
-			Collections.<Object>sort(returnList, PresentationContext.INSTANCE.getMethodElementTypeComparator());
+			Comparator comparator = PresentationContext.INSTANCE.getMethodElementTypeComparator();
+			if (forcePresNameSort)
+				comparator = PresentationContext.INSTANCE.getPresNameMethodElementTypeComparator();
+			Collections.<Object>sort(returnList, comparator);
 		}
 		return returnList;
-	
 	}
 }
diff --git a/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/util/Comparators.java b/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/util/Comparators.java
index 3f3db1a..cad985e 100755
--- a/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/util/Comparators.java
+++ b/plugins/org.eclipse.epf.library.edit/src/org/eclipse/epf/library/edit/util/Comparators.java
@@ -13,9 +13,11 @@
 import java.util.Comparator;
 
 import org.eclipse.emf.ecore.EObject;
+import org.eclipse.epf.library.edit.PresentationContext;
 import org.eclipse.epf.uma.BreakdownElement;
 import org.eclipse.epf.uma.DescribableElement;
 import org.eclipse.epf.uma.MethodElement;
+import org.eclipse.epf.uma.UmaPackage;
 
 import com.ibm.icu.text.Collator;
 
@@ -48,7 +50,7 @@
 
 	};
 	
-	public static final Comparator<Object> REVERSE_NAME_COMPARATOR = new Comparator<Object>() {
+	public static final Comparator<Object> REVERSE_DEFAULT_COMPARATOR = new Comparator<Object>() {
 
 		public int compare(Object o1, Object o2) {
 			if (o1 == o2)
@@ -84,6 +86,8 @@
 		protected abstract int getOrderId(Object obj);
 
 		public int compare(Object o1, Object o2) {
+			o1 = TngUtil.unwrap(o1);
+			o2 = TngUtil.unwrap(o2);
 			if (o1 == o2)
 				return 0;
 			int ret = 0;
@@ -127,4 +131,70 @@
 
 	};
 	
+	public static final Comparator REVERSE_PRESENTATION_NAME_COMPARATOR = new Comparator() {
+		
+		public int compare(Object o1, Object o2) {
+			if (o1 == o2)
+				return 0;
+			if(!(o1 instanceof DescribableElement)) {
+				o1 = TngUtil.unwrap(o1);
+				if(!(o1 instanceof DescribableElement)) {
+					return 0;
+				}
+			}
+			if(!(o2 instanceof DescribableElement)) {
+				o2 = TngUtil.unwrap(o2);
+				if(!(o2 instanceof DescribableElement)) {
+					return 0;
+				}
+			}
+			return oppositeValue(comparePresentationName((DescribableElement) o1, (DescribableElement) o2));
+		}
+
+	};
+
+	public static final Comparator METHOD_TYPE_COMPARATOR = new TypeComparator() {
+		/* (non-Javadoc)
+		 * @see org.eclipse.epf.library.edit.util.Comparators.TypeComparator#getDefaultComparator()
+		 */
+		protected Comparator getDefaultComparator() {
+			return PresentationContext.INSTANCE.getComparator();
+		}
+
+		protected int getOrderId(Object obj) {
+			if (obj instanceof MethodElement) {
+				int id = ((MethodElement) obj).eClass().getClassifierID();
+				if (id == UmaPackage.TERM_DEFINITION) {
+					id = Integer.MAX_VALUE;
+				}
+				return id;
+			}
+			return -1;
+		}
+	};
+	
+	/**
+	 * Always sort by presentation name
+	 */
+	public static final Comparator METHOD_TYPE_PRES_NAME_COMPARATOR = new TypeComparator() {
+		/* (non-Javadoc)
+		 * @see org.eclipse.epf.library.edit.util.Comparators.TypeComparator#getDefaultComparator()
+		 */
+		protected Comparator getDefaultComparator() {
+			return PresentationContext.INSTANCE.getPresNameComparator();
+		}
+
+		protected int getOrderId(Object obj) {
+			if (obj instanceof MethodElement) {
+				int id = ((MethodElement) obj).eClass().getClassifierID();
+				if (id == UmaPackage.TERM_DEFINITION) {
+					id = Integer.MAX_VALUE;
+				}
+				return id;
+			}
+			return -1;
+		}
+	};
+
+	
 }
diff --git a/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/LibraryResources.java b/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/LibraryResources.java
index d45b619..ec48d00 100755
--- a/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/LibraryResources.java
+++ b/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/LibraryResources.java
@@ -91,11 +91,6 @@
 	public static String activityDiagramName;
 	public static String activityDetailDiagramName;
 	public static String wpDependencyDiagramName;
-	public static String SortType_Label;
-	public static String SortType_Manual;
-	public static String SortType_Alphabetic;
-	public static String SortType_ReverseAlphabetic;
-	public static String SortType_MethodType;
 	public static String colon_with_space;
 	
 
diff --git a/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/Resources.properties b/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/Resources.properties
index 1aa2d55..b809cd5 100755
--- a/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/Resources.properties
+++ b/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/Resources.properties
@@ -104,14 +104,6 @@
 activityDetailDiagramName=Activity detail diagram: {0}
 wpDependencyDiagramName=Workpruduct dependency diagram: {0}
 
-# Sort options
-SortType_Label=Sort Type:
-SortType_Manual=Manual
-SortType_Alphabetic=Alphabetic
-SortType_ReverseAlphabetic=Reverse Alphabetic
-SortType_MethodType=Method Type
-
-
 # localize the value based on locale.  for example, 
 # for English, the value is ". "
 #colon_with_space=: 
diff --git a/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/configuration/ConfigurationHelper.java b/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/configuration/ConfigurationHelper.java
index 84a76aa..f8e4168 100755
--- a/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/configuration/ConfigurationHelper.java
+++ b/plugins/org.eclipse.epf.library/src/org/eclipse/epf/library/configuration/ConfigurationHelper.java
@@ -20,9 +20,9 @@
 import org.eclipse.emf.ecore.EObject;
 import org.eclipse.emf.ecore.EStructuralFeature;
 import org.eclipse.epf.library.LibraryPlugin;
+import org.eclipse.epf.library.edit.util.CategorySortHelper;
 import org.eclipse.epf.library.edit.util.SectionList;
 import org.eclipse.epf.library.edit.util.TngUtil;
-import org.eclipse.epf.library.util.CategorySortHelper;
 import org.eclipse.epf.library.util.LibraryUtil;
 import org.eclipse.epf.library.util.ResourceHelper;
 import org.eclipse.epf.uma.Activity;
@@ -1218,7 +1218,7 @@
 		
 		List returnList = realizer.realize(element, feature, values);
 		if ( element instanceof CustomCategory && feature == UmaPackage.eINSTANCE.getCustomCategory_CategorizedElements() ) {
-			returnList = CategorySortHelper.sortCategoryElements(element, returnList.toArray());
+			returnList = CategorySortHelper.sortCategoryElements(element, returnList.toArray(), true);
 		}
 
 		// the following part might not be general to all cases