@@ -18,15 +18,15 @@ public static void main(final String... args) {
1818 private static void keyDemo () {
1919 System .out .println ("KeyDemo" );
2020 final List <String > words = list ("Hello" , "World" , "how" , "are" , "your" , "doing" );
21- final TreeMap <Integer , List <String >> lengthMap = words .groupBy (String ::length );
21+ final TreeMap <Integer , List <String >> lengthMap = words .groupBy (String ::length , Ord . intOrd );
2222
2323 lengthMap .forEach (entry -> System .out .println (String .format ("Words with %d chars: %s" , entry ._1 (), entry ._2 ())));
2424 }
2525
2626 private static void keyValueDemo () {
2727 System .out .println ("KeyValueDemo" );
2828 final List <Integer > xs = list (1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 );
29- final TreeMap <Integer , List <String >> result = xs .groupBy (x -> x % 3 , Integer ::toBinaryString );
29+ final TreeMap <Integer , List <String >> result = xs .groupBy (x -> x % 3 , Integer ::toBinaryString , Ord . intOrd );
3030
3131 result .forEach (entry -> System .out .println (String .format ("Numbers with reminder %d are %s" , entry ._1 (), entry ._2 ())));
3232 }
@@ -35,7 +35,7 @@ private static void keyValueAccDemo() {
3535 System .out .println ("KeyValueAccDemo" );
3636 final List <String > words = list ("Hello" , "World" , "how" , "are" , "your" , "doing" );
3737 final TreeMap <Integer , Integer > lengthCounts =
38- words .groupBy (String ::length , Function .identity (), 0 , (word , sum ) -> sum + 1 , Ord .hashOrd () );
38+ words .groupBy (String ::length , Function .identity (), 0 , (word , sum ) -> sum + 1 , Ord .intOrd );
3939
4040 lengthCounts .forEach (entry -> System .out .println (String .format ("Words with %d chars: %s" , entry ._1 (), entry ._2 ())));
4141 }
0 commit comments