Decorate-sort-undecorate idiom: Difference between revisions

Content added Content deleted
m (Added a comment.)
m (Minor code improvement.)
Line 442: Line 442:
return list.stream().map( s -> new AbstractMap.SimpleEntry<T, R>(s, function.apply(s)) )
return list.stream().map( s -> new AbstractMap.SimpleEntry<T, R>(s, function.apply(s)) )
.sorted( (one, two) -> one.getValue().compareTo(two.getValue()) )
.sorted( (one, two) -> one.getValue().compareTo(two.getValue()) )
.map( p -> p.getKey() ).collect(Collectors.toList());
.map( p -> p.getKey() )
.collect(Collectors.toList());
}
}


}
}

</syntaxhighlight>
</syntaxhighlight>
{{ out }}
{{ out }}