Page 1 of 1

[HD-OCP17/21-Fundamentals Pg 490, Sec. 17.1.6 - the-sort-method]

Posted: Sun Sep 29, 2024 10:49 am
by raphaelzintec
If you want to sort the list in the reverse order, you can change the lambda expression to, (a, b)->
-a.compareTo(b). Observe the minus sign in front of a.compareTo(b).

Or just b.compareTo(a)

dunno why you have not mentioned it

Re: [HD-OCP17/21-Fundamentals Pg 490, Sec. 17.1.6 - the-sort-method]

Posted: Sun Sep 29, 2024 2:19 pm
by admin
Yes, that is fine too.