I wanted to do the same thing, but it looks like that example is for sorting by meta_value.
WIth product attributes the issue appears to be more complicated as they are stored in a serialized format in the database as the '_product_attributes' meta_key value if that makes sense.
From what I can tell, it will be a significantly more involved effort to get WC sorting according to the _product_attributes values themselves.