private SortedSet < Map . Entry < String , List < T > > > entriesSortedByValues ( final Map < String , List < T > > map , final StepMapping < T > stepMapping ) { final Comparator < ? super Entry < String , List < T > > > compare = ( o1 , o2 ) -> { final Comparator < T > compare1 = ( o11 , o21 ) -> { final int compareDate = stepMapping . getFromDate ( o11 ) . compareTo ( stepMapping . getFromDate ( o21 ) ) ; if ( compareDate == 0 ) { final int compareType = stepMapping . getRoleCode ( o11 ) . compareTo ( stepMapping . getRoleCode ( o21 ) ) ; if ( compareType == 0 ) { return stepMapping . getOrg ( o11 ) . compareTo ( stepMapping . getOrg ( o21 ) ) ; } else { return compareType ; } } return compareDate ; } ; Collections . sort ( o1 . getValue ( ) , compare1 ) ; Collections . sort ( o2 . getValue ( ) , compare1 ) ; return compare1 . compare ( o1 . getValue ( ) . get ( 0 ) , o2 . getValue ( ) . get ( 0 ) ) ; } ; final SortedSet < Map . Entry < String , List < T > > > sortedEntries = new TreeSet <> ( compare ) ; sortedEntries . addAll ( map . entrySet ( ) ) ; return sortedEntries ; }
Entries sorted by values .