How to sort an array of objects containing null elements?

后端 未结 5 1828
梦谈多话
梦谈多话 2020-11-27 23:24

In my program an array fClasses of fixed length [7] of objects is created, each object is a class FClass that contains 3 Strings, an <

5条回答
  •  佛祖请我去吃肉
    2020-11-27 23:58

    With Apache Commons Collections 4 you can use ComparatorUtils to do that:

    Collections.sort(arr, ComparatorUtils.nullLowComparator(ComparatorUtils.NATURAL_COMPARATOR));
    

提交回复
热议问题