How to block index with "?" in collection page

Although shopify’s robots.txt blocks the index of collection pages with “?sort_by=” by default, there are still a lot of missing pages. Google search console reminds me that there are tens of thousands of collection pages with “?sort_by=” Blocked by robots, but indexed,

So how to remove index for collection pages with “?sort_by=”

{% if template contains “search” or template contains “cart” or template contains “checkout” or template contains “account” %}

{% endif %}

This doesn’t help me exclude collection pages with “?sort_by=” to index

I want to delete the index with “?sort_by=” in the collection page, although the robots.txt file is blocked, it is still indexed, so how to solve it through “noindex”

Liquid doesn’t seem to be able to determine which pages have “?sort_by=”