您的位置:首页 > 运维架构

Collections sort by Entity property like Date

2012-11-22 01:02 337 查看
For example, Tweet entity has two properties: Id, tweetCreateDate. I have a list of tweets, I need to sort them by tweetCreateDate desc. Here is the way I do it.

Collections.sort(tweets, new Comparator<Tweet>() {
public int compare(Tweet t1, Tweet t2) {
return t2.getTweetCreateDate().compareTo(t1.getTweetCreateDate());
}
});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: