public static < T > void sort ( T [ ] array , String sortBy , boolean ascending , boolean nullsFirst ) { if ( array == null || array . length == 0 ) { return ; } if ( sortBy . equals ( "this" ) ) { Arrays . sort ( array , thisUniversalComparator ( ascending , nullsFirst ) ) ; return ; } Object object = array [ 0 ] ; Map < String , FieldAccess > fields = null ; if ( object != null ) { fields = BeanUtils . getFieldsFromObject ( object ) ; } else { for ( int index = 1 ; index < array . length ; index ++ ) { object = array [ index ] ; if ( object != null ) { fields = BeanUtils . getFieldsFromObject ( object ) ; break ; } } } if ( fields != null ) { final FieldAccess field = fields . get ( sortBy ) ; if ( field != null ) { Arrays . sort ( array , Sorting . universalComparator ( field , ascending , nullsFirst ) ) ; } } }
Sort an array .