Could someone please help me out with the following problem in java. I have a simple class defined as below:
public class Expr {
public long total_apparitions;
public String expression=new String();
public Expr(long total,String expr){
this.total_apparitions=total;
this.expression=expr;
}
public void increment(long aparitions){
total_apparitions+=aparitions;
}
}
I want to sort an array of Expr objects by the total_apparitions field, using the Arrays.sort built-in function. How do I specify to the Arrays.sort function the comparison factor? Thanks a lot.