How to sort a List<Object> alphabetically using Object name field

后端 未结 16 1494
暗喜
暗喜 2020-11-28 06:00

I have a List of Objects like List p.I want to sort this list alphabetically using Object name field. Object contains 10 field and name field is o
16条回答
  •  伪装坚强ぢ
    2020-11-28 06:11

    something like

      List theList = … ;
      Collections.sort (theList,
                        new Comparator ()
                        { int compare (final FancyObject a, final FancyObject d)
                              { return (a.getName().compareTo(d.getName())); }});
    

提交回复
热议问题