categories – WooCommerce products sorting by primary category first

I have a site with woocommerce and yoast seo plugin. I want to list the products on category archive page, by making the products of primary category (from yoast plugin) come first. Currently it does not do that. It is listing the products randomly or by menu order. The products have multiple categories assigned. For ex. the page of ‘Fashion’ category archive should list the products with primary category ‘Fashion’ to come first.
Thanks