Progrmatically change option positions?

Does anyone know how I can programatically change option positions for many products at once? I know CS-Cart uses the hash field which from what i can tell is stored in the order the options are (i.e. size, color) but i want to change it to color first then size.

As far as I can tell I can't just update the position field in the database I have to do more than that. Is there a function or hook I can use to do this?