Collection<IInvokedMethod> invokedMethods = suite.getAllInvokedMethods();
if (alphabetical) {
@SuppressWarnings({"unchecked"})
Comparator<? super ITestNGMethod> alphabeticalComparator = new Comparator(){
public int compare(Object o1, Object o2) {
IInvokedMethod m1 = (IInvokedMethod) o1;
IInvokedMethod m2 = (IInvokedMethod) o2;
return m1.getTestMethod().getMethodName().compareTo(m2.getTestMethod().getMethodName());
}
};
Collections.sort((List) invokedMethods, alphabeticalComparator);
}