例如最新的文章的排序要在最高層~
ArrayList
升冪 ascending
Collections.sort(myData, new Comparator
@Override
public int compare(News n1, News n2) {
return n1.Id - n2.Id;
}
});
descending 降冪
Collections.sort(myData,
Collections.reverseOrder(new Comparator
@Override
public int compare(News n1, News n2) {
return n1.Id - n2.Id;
}
}));
沒有留言:
張貼留言