Sort objects in ArrayList by date?

后端 未结 14 2153
生来不讨喜
生来不讨喜 2020-11-22 06:58

Every example I find is about doing this alphabetically, while I need my elements sorted by date.

My ArrayList contains objects on which one of the datamembers is a

14条回答
  •  醉酒成梦
    2020-11-22 06:59

    This is how I solved:

    Collections.sort(MyList, (o1, o2) -> o1.getLastModified().compareTo(o2.getLastModified()));
    

    Hope it help you.

提交回复
热议问题