Use list.sort
instead:
list.sort((o1, o2) -> o1.getItem().getValue().compareTo(o2.getItem().getValue()));
and make it more succinct using Comparator.comparing
:
list.sort(Comparator.comparing(o -> o.getItem().getValue()));
After either of these, list
itself will be sorted.
Your issue is that
list.stream.sorted
returns the sorted data, it doesn't sort in place as you're expecting.