I'm have the following objects:
List<CartItem> cartItemsList = cart.getItems().stream()
.sorted(Comparator.comparingDouble(f -> f.getProduct().getPrice()))
.collect(Collectors.toList());
Map<Product, Map<Customization, List<CartItem>>> map =cartItemsList.stream()
.collect(Collectors.groupingBy(CartItem::getProduct,
Collectors.groupingBy(CartItem::getCustomizations)));
My issue is about map: because I need to preserve order, defined in the first list(cartItemsList) , map isn't a good solution. Have I to use linkedHashMap(or any other solution) to preserve order and how do that?