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());
}
});