Sorting products in cart

Hi.
I’ve managed to customize the look of individual items in the cart, via customization of <item-line>, but I would like to go a step further and customize the order in which the items are drawn, using information in the metadata field. This would allow me to sort and group the products.
I’m assuming I’d have to customize the <item-list>, but the documentation doesn’t provide a default template or example on how to do that.
Is it possible to sort the items in the cart?