私の簡単な例 (コンパイルされた作業コード) は、果物を重量で並べ替えません。
import java.util.Arrays;
public class Test {
    public static class Fruit implements Comparable<Fruit> {
        public int weight = 0;
        public Fruit(int w) { weight = w; }
        // compare this fruit to a given fruit f
        public int compareTo(Fruit f) {
            return (weight > f.weight) ? 1 : 0;
        }
    }
    public static void main(String[] args) {
        // get some fruits (we intentionally create a box for 100 fruits)
        Fruit[] fruits = new Fruit[100];
        for (int i = 0; i < 10; i++) {
            fruits[i] = new Fruit((int)(Math.random() * 50 + 1));
        }
        // sort fruits by weight
        Arrays.sort(fruits, 0, 10);
        // print fruit weights
        for (int i = 0; i < 10; i++) {
            System.out.print(fruits[i].weight + " ");
        }
    }
}
なぜそうなのですか?
わかりました、私の問題 (果物についてではありません) では、ペアごとに等しくないオブジェクトがあります。そのため、あるオブジェクトが別のオブジェクトよりも大きいか小さいと考えました。では、0 (オブジェクトが等しい) が決して起こらないことがわかっている場合、この状況をどのように処理できますか?