I want to sort the elements and group them as follows. How can I achieve this using the sort, group and java thread section on.
The input enters the streams, which means that after receiving the lower input, after some time an input may occur, such as A16.17, the data structure should be reorganized and regrouped.
Input A10, A4, A11, A3, A12, A15 .... B19, B2, B20 ...
Output A3-A4, A10-A12, A15, B2, B19-B20.
I could sort as below
array.sort(Comparator .comparing(...)
.thenComparing(Comparator.comparing(...)));
but not sure how to split and regroup to input strings using streams in the most optimized way.
array.stream().collect(Collectors.partitionBy(...))
What should be the logic in the function for the section in above to achieve the grouping of consecutive orders?