How can I maintain product order while using number pagination and sort_by code?

I use this code to paginate on collections page


    {% if paginate.previous.is_link %}
    - 

    {% endif %}
    {% assign count = paginate.pages %}
    {% for part in (1..count) %}
    - {{ forloop.index }}

    {% endfor %}
    {% if paginate.next.is_link %}
    - 
    {% endif %}
  

The arrows works fine, but when you have an order by, the numbers only paginate by default, causing the order of products to be lost

I can add by url the order_by parameter ?