@Override
		public int compare(ManagedMenuItem m1, ManagedMenuItem m2) {
			int result = groupComparator.compare(m1.getGroup(), m2.getGroup());
			if (result != 0) {
				return result;
			}

			// the groups are the same, check the subgroups
			String subGroup1 = m1.getSubGroup();
			String subGroup2 = m2.getSubGroup();

			result = subGroup1.compareTo(subGroup2);
			if (result != 0) {
				return result;
			}

			// when the group is the same, sub-sort by the item's name
			String text1 = m1.getMenuItemText();
			String text2 = m2.getMenuItemText();

			result = text1.compareTo(text2);
			if (result == 0) {
				// When the names are the same, we have to compare even further, or the items
				// will not all appear in the set, as the set will consider them equal. Just use
				// something unique that is guaranteed not to change in this VM session.  This 
				// will only be equal if the objects are the same reference.
				return System.identityHashCode(m1) - System.identityHashCode(m2);
			}
			return result;
		}
This comparator puts null grouped items at the top of the menu so that universal popup
actions are always at the bottom (e.g., Copy for tables).
Ghidra/Framework/Docking/src/main/java/docking/menu/MenuManager.java