How do we filter products in each category?

We filter each category of our products according to several criterias from which first is always "we recommend". Products are automatically ranked by popularity (number of products sold, number of views, etc.) It is also taken into account whether it is a new product or final sale for example. These products have a better chance to appear first in our selection. The final ranking is decided by an algorithm.