Hi, team

I have two suggestions


Firstly:


If we can provide a new API for grouping (java.util.stream.Collectors )
such as:
userList.stream().collect(Collectors.groupingBy(User::getName, User::getCity))
userList.stream().collect(Collectors.groupingBy("-", User::getName, 
User::getCity, User::getId));// key is "name-city", value is List after 
being grouped


It helps us to do grouping with less code. and It looks cooler for lambda.


And I've provided a simple demo. 
demo: https://github.com/1015770492/CollectorsDemo/blob/master/src/main/java/com/example/demo/MultiGroupByDemo.java
issue: https://github.com/openjdk/jdk/pull/9719


Secondly:


similarly, if we can provide new api for sort with stream. 
It can be??
userList.stream().sorted(User::getAge) 
or userList.stream().sorted(User::getName)  
or userList.stream().sorted(User::getName, User::getAge)


userList.stream().sorted(User::getAge) age is a Integer or int type ,it 
is Comparable, So if we can use the Function 
reference implements sort.


String implements the Comparable Interface but we do not use 
the features.




userList.stream().sorted(User::getCity, User::getName)

multi-condition sort we can transfor to String sort. 




best regards
Yu, Jinhua
1015770...@qq.com

Reply via email to