In version 1.4 you have to change in classes/Product.php on line 2136:
ORDER BY agl.`public_name`, al.`name`');
to
ORDER BY agl.`id_attribute_group`, al.`name`');
and the same modifications must be made in classes/Cart.php, on line 420, for the attributes to be sorted in the same way in the shopping cart.