Java: How to sort custom type ArrayList

前端 未结 4 1819
时光取名叫无心
时光取名叫无心 2021-01-14 04:57

I have a custom type Position(x,y,z),now I create a ArrayList, i want to sort this array ordered by the value of z, from small to b

4条回答
  •  囚心锁ツ
    2021-01-14 05:10

    You need to implement your Comparator, which will compare the value of the z attribute.

提交回复
热议问题