public List<Posts> sortPostsbyPcount(List<Posts> list) {
Collections.sort(list, new Comparator() {
@Override
public int compare(Object o1, Object o2) {
Posts posts1 = (Posts) o1;
Posts posts2 = (Posts) o2;
if (posts1.getPcount() > posts2.getPcount()) {
return -1;
} else if (posts1.getPcount() == posts2.getPcount()) {
return 0;
} else {
return 1;
}
}
});
return list;
} |
|