sorting on keys on the MapStream
aruld at acm.org
Sat Sep 15 12:34:45 PDT 2012
I was trying to rewrite the FunctionalCollectionComputation  example
using the updated APIs in latest build .
.mapped(name -> name.length())
.filterValues((length) -> length >= 4)
.sorted((i1, i2) -> i1 - i2) or sorted((name1, name2) ->
name1.length() - name2.length())
.forEach((name, length) -> System.out.println(name + '\t' +
I had to introduce a swap() on the MapStream so I can sort it on the keys.
Another option would be to use sorted((name1, name2) -> name1.length() -
name2.length()) which won't require a swap().
Down to 4 bulk ops calls from its original version, pretty sweet!
I understand these APIs are undergoing heavy changes. sorted() throws NPE
in MapPipeline which returns null. so this example won't work under latest
More information about the lambda-dev