java 7 等同于 SomeClass::compareTo 表达式是什么?

What is the java 7 equivalent to SomeClass::compareTo expression?

我的目的是创建自定义排序方法:

public void mySort
{
    this.sort(SomeClass::compareTo());
}

这在 Java 8 中工作得很好,但是,Java 7 很生气!如果自定义 ArrayList(由 this 引用)中的对象 (SomeClass) 具有预定义的比较器,我什至需要自定义排序方法还是 sort() 方法会处理它进入他们?

List.sort(Comparator) 的文档说,如果您传入 null,那么列表将根据它的 自然顺序 进行排序。因此,如果您的 class 实现了 Comparable,您应该能够传入 null.

根据 Comparable 接口文档自然排序 的定义:

This interface imposes a total ordering on the objects of each class that implements it. This ordering is referred to as the class's natural ordering, and the class's compareTo method is referred to as its natural comparison method.

上面的解决方案并没有最终适用于我的实施。也就是说,Collections.sort(this.myList) 创造了奇迹。谢谢你的建议!