I'm interested in sorting a list from a stream. This is the code I'm using:
list.stream()
.sorted((o1, o2)->o1.getItem().getValue().compareTo(o2.getItem().getValue()))
.collect(Collectors.toList());
Am I missing something? The list is not sorted afterward.
It should sort the lists according to the item with the lowest value.
for (int i = 0; i < list.size(); i++)
{
System.out.println("list " + (i+1));
print(list, i);
}
And the print method:
public static void print(List<List> list, int i)
{
System.out.println(list.get(i).getItem().getValue());
}
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…