Update xaxes, setting categoryarray to a variable which is a list of categorical values

Hi, I am working with a heatmap and would like to control the ordering of the categorical values by providing the ordering from from a variable which is a list, but separate from the ordering of the dataframe used to construct the figure.

It works if I manually write a list like below code:
update_xaxes(title_font=dict(size=24, family=‘Arial’),side=“bottom”, categoryorder=‘array’, categoryarray=[“A”,“B”,“D”,“C”])

However, it would be much more efficient if I can just refer to a variable that contains a list, such as the attempt below:

update_xaxes(title_font=dict(size=24, family=‘Arial’),side=“bottom”, categoryorder=‘array’, categoryarray=@sorted_list)

But I can’t get this to work. Is it possible at all to refer to a variable from update_xaxes, or is there an error in my code?

Best wishes
Mikkel C.