Consider this class.
public class DynamicField implements Comparable<DynamicField> {
String title;
int position;
int order;
@Override
public int compareTo(DynamicField o) {
if(position < o.position)
return -1;
if(position > o.position)
return 1;
if(order < o.order)
return -1;
if(order > o.order)
return 1;
return title.compareTo(o.title);
}
}
Is the compareTo method correct if I want to sort by title, position and then order?