MBeanOp op1 = (MBeanOp) o1; MBeanOp op2 = (MBeanOp) o2; int compare = op1.getName().compareTo(op2.getName()); if( compare == 0 ) compare = op1.getArgCount() - op2.getArgCount(); return compare;