Warm tip: This article is reproduced from serverfault.com, please click

Sorting ArrayList with Lambda in Java 8

发布于 2014-05-16 18:08:36

Could somebody show me a quick example how to sort an ArrayList alphabetically in Java 8 using the new lambda syntax.

Questioner
Jeef
Viewed
0
poosliver 2014-05-17 02:16:45

For strings this would work

arrayList.sort((p1, p2) -> p1.compareTo(p2));