Sorting an ArrayList with Objects

Sorting an ArrayList based on an integer field

public class DataPoint {
  public String Name;
  public int Counter;
}

Collections.sort(largeList, new Comparator<DataPoint>() {
  public int compare(DataPoint a, DataPoint b) {
    return (a.Counter - b.Counter);
  }
});

Sorting an ArrayList based on a double field

public class DataPoint {
  public String Name;
  public double Counter;
}

Collections.sort(largeList, new Comparator<DataPoint>() {
  public int compare(DataPoint a, DataPoint b) {
    return (Double.compare(a.Counter, b.Counter));
  }
});

Sorting an ArrayList based on String field

public class DataPoint {
  public String Name;
  public double Counter;
}

Collections.sort(largeList, new Comparator<DataPoint>() {
  public int compare(DataPoint a, DataPoint b) {
    return (a.Name.compareTo(b.Name));
  }
});