jjzjj

TreeSets

全部标签

java - 如何使用 java8 流对 TreeSets 列表进行排序

我的列表包含像[1,3,5][2,6,4]等集合,它们的大小都相同。我试过这样做,但它似乎不起作用。List>block;for(TreeSett:block){block.stream().sorted((n,m)->n.compareTo(m)).collect(Collectors.toSet());}我想要的最终结果是[1,2,3][4,5,6]。我可以尝试将所有元素添加到ArrayList中并对其进行排序,然后创建一个包含TreeSet的新List。但是是否存在某种单一的衬垫?更新:Listlist=newArrayList();for(TreeSett:block){for