Hi how can I use compare to first sort an array alphabetically and then according to length. (longer words before short words) e.g. first appletree, apple, baron.
@Override
public int compare(Term o1, Term o2) {
// TODO Auto-generated method stub
if (o1.getTerm().compareTo(o2.getTerm()) < 1 && o1.getTerm().length() > o2.getTerm().length()) {
return -1;
}
else
return 0;
}
With the example above I get the words alphabetically but not lengthwise