How to rearrange the order of product.options_with_values before it is rendered

Hi,

I’m wondering if it is possible to rearrange the options in product.options_with_values?

Prior to rendering, the array product.options_with_values of product options must be sorted manually and reassigned back to product.options_with_values.

For instance, the product has three options ( Colour, Size, FormType).

Prior to the rendering of the options on the front end, the order must be changed to (Size, FormType, Colour).

Array sorting by option “name” can not be applied here. Also, the general array sorting does not work, e.g.

{% assign product.options_with_values = product.options_with_values | sort: “name” | reverse %}

Any idea how this can be achieved?

Thanks in advance!