I needed to make another order in order for this to work. Its seem to work perfect thanks! Do you have the code for doing the same thing but on the invoice. Do you also have the code to display the products on alphabetical order on both invoice as packingslip?
Thanks for the quick reply! I tried your code, but I than I got a white page. I upgraded the php version from 7.1 to 7.2 and now the website seem to work, but the order is still in the order of placing it in the cart.