Browse - programming tips - java sort arraylistDate: 2010aug7 Language: java Q. How do I sort an ArrayList? A. ArrayList<MyEntry> a; // Add things to array a Collections.sort(a, new customCompare); Where customCompare is: public class customCompare implements java.util.Comparator<Entry> { public int compare(MyEntry a, MyEnry b) { return a.field1.compareTo(b.field1); } }
Add a commentSign in to add a comment | Advertisements:
|