@ErSanjay a filter does not work inside a for loop tag
You need to pre-assign to a variable that collection with the filter.
Then use that variable in the forloop.
{% assign available_collection = collection.products | sort: 'available' -%)
{%- for product in available_collection -%}
...
Making sure you look through the dev docs to understand what an “available” product means in shopify liquid. https://shopify.dev/docs/api/liquid/objects/product#product-available