For the cart, you can change the line:
$query='SELECT a.*,b.*,c.* FROM '.hikashop_table('cart').' AS a LEFT JOIN '.hikashop_table('cart_product').' AS b ON a.cart_id = b.cart_id LEFT JOIN '.hikashop_table('product').' AS c ON b.product_id=c.product_id WHERE '.implode(' AND ',$filters).' ORDER BY b.cart_product_modified ASC';
in the file administrator/components/com_hikashop/classes/cart.php to something like this:
$query='SELECT a.*,b.*,c.* FROM '.hikashop_table('cart').' AS a LEFT JOIN '.hikashop_table('cart_product').' AS b ON a.cart_id = b.cart_id LEFT JOIN '.hikashop_table('product').' AS c ON b.product_id=c.product_id WHERE '.implode(' AND ',$filters).' ORDER BY b.cart_product_code ASC';
For the orders, it's the line:
$query = 'SELECT a.* FROM '.hikashop_table('order_product').' AS a WHERE a.order_id = '.(int)$order->order_id;
of the file administrator/components/com_hikashop/classes/order.php that you want to change to something like this:
$query = 'SELECT a.* FROM '.hikashop_table('order_product').' AS a WHERE a.order_id = '.(int)$order->order_id.' ORDER BY order_product_code ASC';
Please note that we cannot guarantee the proper functioning of HikaShop with these modifications and you might have some surprises as the system wasn't designed to work like that. Note also that you'll loose your changes when you update HikaShop.