How to sort an arraylist of objects java?

后端 未结 6 1069
失恋的感觉
失恋的感觉 2020-12-10 16:26

So I want an arraylist of objects in java.

I have object1.number and object2.number, object3.number, etc... but those objects

6条回答
  •  时光取名叫无心
    2020-12-10 17:08

    Implement your own comparer:

    Arrays.sort(yourArray, new Comparator() {
            @Override
            public int compare(YourClass o1, YourClass o2) {
                //compare object properties
            }
    });
    

提交回复
热议问题