I\'m using java lambda to sort a list.
how can I sort it in a reverse way?
I saw this post, but I want to use java 8 lambda.
Here is my code (I used
You can adapt the solution you linked in How to sort ArrayList in Java in decreasing order? by wrapping it in a lambda:
.sorted((f1, f2) -> Long.compare(f2.lastModified(), f1.lastModified())
note that f2 is the first argument of Long.compare, not the second, so the result will be reversed.
Long.compare