Hello Merete,
This transformation is applied separately to each row of the ContentTable therefore it is too late to attempt to sort it here. There are two possible ways how to achieve your goal, but they will both require significant customization.
One possibility is to order the ShoppingCart.ContentTable according to your own logic each time the ShoppingCart is created or modified. This would also sort any shopping cart checkout process content or preview listings.
Or, you could create a
Custom Macro Method, which would take the unsorted ContentTable as a parameter, sort it and apply transformation to it in the API.
Regards,
Josef Dvorak