Sorting objects within a Set by a String value that all objects contain

后端 未结 7 960
北荒
北荒 2021-01-01 01:30

Ok this is a tricky one. I have a list of Sets. I would like to sort the objects in the Sets in an order.

Imagine each set as repressenting a class in a school. Each

7条回答
  •  暖寄归人
    2021-01-01 02:18

    You may want to look at using a SortedSet for example a TreeSet. This allows you to provide a Comparator which in your case can compare the name of the Person.

提交回复
热议问题