Tuesday, May 10, 2011

Java sort list -- Collections.sort sample




public static void Sort(List<Movies> items) {
Collections.sort(items, SENIORITY_ORDER);
}
static final Comparator<Movies> SENIORITY_ORDER =
        new Comparator<Movies>() {
public int compare(Movies e1, Movies e2) {
if (e1.getReleaseDate().after(e2.getReleaseDate()))
return 1;
else
return -1;
}
};

No comments:

Post a Comment