<meta http-equiv="Content-Type" content="text/html; charset=GB18030"><div>Hi, team</div><div><br></div><div>I have two suggestions</div><div><br></div><div>Firstly:</div><div><br></div><div><code class="notranslate" style="box-sizing: border-box; padding: 0.2em 0.4em; margin: 0px; background-color: var(--color-neutral-muted); border-radius: 6px;"><font color="#24292f" face="-apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji">If we can provide a new API for grouping (</font></code><span style="background-color: rgba(175, 184, 193, 0.2); color: rgb(36, 41, 47); font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 11.9px;">java.util.stream.Collectors </span><span style="color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; background-color: var(--color-neutral-muted);">)</span></div><div><font color="#24292f" face="ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace"><span style="font-size: 12px;">such as:</span></font></div><div><code class="notranslate" style="box-sizing: border-box; padding: 0.2em 0.4em; margin: 0px; background-color: var(--color-neutral-muted); border-radius: 6px;"><font color="#24292f" face="-apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji"></font><font color="#24292f" face="ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace"><span style="font-size: 12px;">userList.stream().collect(Collectors.groupingBy(User::getName, User::getCity))</span></font></code></div><div><code class="notranslate" style="box-sizing: border-box; padding: 0.2em 0.4em; margin: 0px; background-color: var(--color-neutral-muted); border-radius: 6px; font-size: 12px;"><font color="#24292f" face="ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace">userList.stream().collect(Collectors.groupingBy("-", User::getName, User::getCity, User::getId));// key is "name-city", value is </font></code><font color="#24292f" face="ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace"><span style="font-size: 12px;">List after being grouped</span></font></div><div><br></div><div><span style="color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";">It helps us to do grouping with less code. and </span><font color="#24292f" face="-apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji">It looks cooler for lambda.</font></div><div><font color="#24292f" face="-apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji"><br></font></div><div><span style="color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";">And </span><span style="color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";">I've provided a simple demo. </span></div><div>demo: https://github.com/1015770492/CollectorsDemo/blob/master/src/main/java/com/example/demo/MultiGroupByDemo.java</div><div>issue: https://github.com/openjdk/jdk/pull/9719</div><div><br></div><div>Secondly:</div><div><br></div><div>similarly, if we can provide new api for sort with stream. </div><div>It can be£º</div><div><span style="color: rgb(36, 41, 47); font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 12px;">userList.stream().sorted(User::getAge) </span></div><div><span style="color: rgb(36, 41, 47); font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 12px;">or </span><span style="color: rgb(36, 41, 47); font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 12px;">userList.stream().sorted(User::getName)  </span></div><div><span style="color: rgb(36, 41, 47); font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 12px;">or </span><span style="color: rgb(36, 41, 47); font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 12px;">userList.stream().sorted(User::getName, User::getAge)</span></div><div><br></div><div><span style="color: rgb(36, 41, 47); font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 12px;">userList.stream().sorted(User::getAge) age is a Integer or int type ,it is </span><font color="#24292f" face="ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace"><span style="font-size: 12px;">Comparable, So if we can use the Function reference implements sort.</span></font></div><div><br></div><div>String implements the <span style="color: rgb(36, 41, 47); font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 12px;">Comparable Interface but we do not use the </span><font color="#24292f" face="ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace"><span style="font-size: 12px;">features.</span></font></div><div><br></div><div><br></div><div><div><span style="color: rgb(36, 41, 47); font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 12px;">userList.stream().sorted(User::getCity, User::getName)</span></div></div><div>multi-condition sort we can transfor to String sort. </div><div><br></div><div><br></div><div>best regards</div><div>Yu, Jinhua</div><div>1015770492@qq.com</div><div><br></div><div><font color="#24292f" face="ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace"><span style="font-size: 12px;"><br></span></font></div><div><div><br></div></div><div><span style="color: rgb(36, 41, 47); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";"><br></span></div><div><br></div>