Want to get the product sort collection product best-selling, price-descending and price_ascending

I want to get the product sort collection product best-selling, price-descending and price_ascending usign custom code.

{% assign productsnow = collection.products | sort: "best-selling" %}   
{% for product in productsnow limit: 4 %}         
{{product .title}}
{% endfor %}

{% assign expensiveproduct = collection.products | sort: 'price-descending' %}
{% for product in expensiveproduct limit: 4 %}         
{{product .title}}
{% endfor %}

{% assign productascending = collection.products | sort: "price-ascending" %}
{% for product in productascending limit: 4 %}
{{product .title}}
{% endfor %}

Could you please let me know the issue how to fix this.

Shopify already has this based on their AI

“Sort by best selling”

Yes, I agree that shopify already has this based on their AI “Sort by best selling” . But we need to achive this using custom code. We need to built some custom feature.