returns a consistent ordering over two elements even if one of them is null as long as compareto is stable , of course . there 's a `` trickier '' solution with xor at http://stackoverflow.com/a/481836 but the straightforward answer seems better . concode_field_sep PlaceHolder placeHolder concode_field_sep Comparator<boolean[]> getBooleanArrayComparator concode_elem_sep Comparator<T> chain concode_elem_sep Comparator<T> chain concode_elem_sep Comparator<T> chain concode_elem_sep int compareLists concode_elem_sep Comparator<List<C>> getListComparator concode_elem_sep Comparator getStringRepresentationComparator concode_elem_sep Comparator<C[]> getArrayComparator concode_elem_sep Comparator<T> reverse concode_elem_sep Comparator<T> nullSafeNaturalComparator
int function ( final T arg0 , final T arg1 ) { if ( arg0 == null ) { if ( arg1 == null ) { return 0 ; } return - 1 ; } else { if ( arg1 == null ) { return 1 ; } return arg0 . compareTo ( arg1 ) ; } }