i must create Sorted method, called with map arguments and lambda-expression. The method returns a sorted version of any map passed as the first argument, and the sort order is determined by the lambda expression, given as the second argument.
i created something like that(dont work correctly):
public Map sorted(Map map, Function<Set> funct){
System.out.println(map.entrySet()
.stream()
.sorted((Comparator) funct)
.collect(Collectors.toList()));
return null;
}
Any ideas ?
Thanks for help ;)
Comparator<Map.Entry<KeyType,ValueType>>to thesortedmethod.Map<K,V> sorted = new TreeMap<>(comparator); sorted.putAll(map); return sorted;