I'm trying to sort items in the shopping cart. I've been able to do it with liquid templating. But when I proceed to the checkout page, the quantity of the products are different from the one displayed in the shopping cart. I've noticed that items in the cart.items array don't have the same order then the items in the shopping cart page. In the cart.items array the order of the items is equal to the same order product are added to the cart. For example, the last product added will be the first in the cart.items array.
Does someone know what do I need to do to be able to correctly sort items in the shopping cart ?