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()); } });
相关文章推荐
- mappedBy reference an unknown target entity property
- mappedBy reference an unknown target entity property: com.sq.entity.Address.tt_user in com.sq.entit
- 解决:ould not find a getter for porDate in class com.bc.bean.PortalSheet Caused by: org.hibernate.PropertyNotFoundException: Could
- mappedBy reference an unknown target entity property解决方法
- Magento 默认排序为最新产品在前 How to sort Magento products by date added as default
- How to query_posts using meta_query to orderby meta_key AND have a secondary sort by date?
- [原创]java WEB学习笔记61:Struts2学习之路--通用标签 property,uri,param,set,push,if-else,itertor,sort,date,a标签等
- org.hibernate.AnnotationException: mappedBy reference an unknown target entity property
- mappedBy reference an unknown target entity property解决方法
- Error while updating property 'nativeBackgroundAndroid' of a view managed by:RCTView
- Sort c# Dictionary by Value
- java List 排序 Collections.sort() 对 List 排序
- Java-Collections的sort方法对 list 进行排序
- The path to the driver executable must be set by the webdriver.gecko.driver system property
- Codeforces Round #259 (Div. 2) B. Little Pony and Sort by Shif
- Exception thrown by getter for property
- Java----Collections的Sort排序小测试
- java Collections.sort()排序。List排序
- org.hibernate.AnnotationException: property from @OrderBy clause not found
- Hive中SELECT TOP N的方法(order by与sort by)