@@ -35,7 +35,7 @@ public final int compare(final Human h1, final Human h2) {
3535 public final void whenSortingEntitiesByName_thenCorrectlySorted () {
3636 final List <Human > humans = Lists .newArrayList (new Human ("Sarah" , 10 ), new Human ("Jack" , 12 ));
3737
38- Collections .sort (humans , (final Human h1 , final Human h2 ) -> h1 .getName ().compareTo (h2 .getName ()));
38+ humans .sort ((final Human h1 , final Human h2 ) -> h1 .getName ().compareTo (h2 .getName ()));
3939
4040 Assert .assertThat (humans .get (0 ), equalTo (new Human ("Jack" , 12 )));
4141 }
@@ -52,7 +52,7 @@ public final void givenLambdaShortForm_whenSortingEntitiesByName_thenCorrectlySo
5252 @ Test
5353 public final void whenSortingEntitiesByNameThenAge_thenCorrectlySorted () {
5454 final List <Human > humans = Lists .newArrayList (new Human ("Sarah" , 12 ), new Human ("Sarah" , 10 ), new Human ("Zack" , 12 ));
55- Collections .sort (humans , (lhs , rhs ) -> {
55+ humans .sort ((lhs , rhs ) -> {
5656 if (lhs .getName ().equals (rhs .getName ())) {
5757 return lhs .getAge () - rhs .getAge ();
5858 } else {
@@ -67,36 +67,41 @@ public final void givenComposition_whenSortingEntitiesByNameThenAge_thenCorrectl
6767 final List <Human > humans = Lists .newArrayList (new Human ("Sarah" , 12 ), new Human ("Sarah" , 10 ), new Human ("Zack" , 12 ));
6868 final Comparator <Human > byName = (h1 , h2 ) -> h1 .getName ().compareTo (h2 .getName ());
6969 final Comparator <Human > byAge = (h1 , h2 ) -> Ints .compare (h1 .getAge (), h2 .getAge ());
70- Collections .sort (humans , byName .thenComparing (byAge ));
70+
71+ humans .sort (byName .thenComparing (byAge ));
7172 Assert .assertThat (humans .get (0 ), equalTo (new Human ("Sarah" , 10 )));
7273 }
7374
7475 @ Test
7576 public final void whenSortingEntitiesByAge_thenCorrectlySorted () {
7677 final List <Human > humans = Lists .newArrayList (new Human ("Sarah" , 10 ), new Human ("Jack" , 12 ));
77- Collections .sort (humans , (h1 , h2 ) -> Ints .compare (h1 .getAge (), h2 .getAge ()));
78+
79+ humans .sort ((h1 , h2 ) -> Ints .compare (h1 .getAge (), h2 .getAge ()));
7880 Assert .assertThat (humans .get (0 ), equalTo (new Human ("Sarah" , 10 )));
7981 }
8082
8183 @ Test
8284 public final void whenSortingEntitiesByNameReversed_thenCorrectlySorted () {
8385 final List <Human > humans = Lists .newArrayList (new Human ("Sarah" , 10 ), new Human ("Jack" , 12 ));
8486 final Comparator <Human > comparator = (h1 , h2 ) -> h1 .getName ().compareTo (h2 .getName ());
85- Collections .sort (humans , comparator .reversed ());
87+
88+ humans .sort (comparator .reversed ());
8689 Assert .assertThat (humans .get (0 ), equalTo (new Human ("Sarah" , 10 )));
8790 }
8891
8992 @ Test
9093 public final void givenMethodDefinition_whenSortingEntitiesByNameThenAge_thenCorrectlySorted () {
9194 final List <Human > humans = Lists .newArrayList (new Human ("Sarah" , 10 ), new Human ("Jack" , 12 ));
92- Collections .sort (humans , Human ::compareByNameThenAge );
95+
96+ humans .sort (Human ::compareByNameThenAge );
9397 Assert .assertThat (humans .get (0 ), equalTo (new Human ("Jack" , 12 )));
9498 }
9599
96100 @ Test
97101 public final void givenInstanceMethod_whenSortingEntitiesByName_thenCorrectlySorted () {
98102 final List <Human > humans = Lists .newArrayList (new Human ("Sarah" , 10 ), new Human ("Jack" , 12 ));
99- Collections .sort (humans , Comparator .comparing (Human ::getName ));
103+
104+ humans .sort (Comparator .comparing (Human ::getName ));
100105 Assert .assertThat (humans .get (0 ), equalTo (new Human ("Jack" , 12 )));
101106 }
102107
0 commit comments