一、实体类实现Comparable<Vacation>, Parcelable 接口
eg:public class Vacation implements Comparable<Obj>, Parcelable
二、重写方法compareTo,用于比较两个类的对应的两个属性
eg: @Override
public int compareTo(Vacation another) {
return this.getTime().compareTo(another.getTime());
}
三、对于获取到的数据List<Obj> objList= new ArrayList<Obj>(),向里面添加好自己将要用来排序的数据,示例如下:
// 升序排列输出 Collections.sort(objList);
// 降序排列输出
Collections.sort(objList, Collections.reverseOrder());
此时objList中的数据就为已经按照个人排序方式排好的数据。