How to show instock first and then outstock products woocommerce?

I have one question if i make sorting order instock first then outstock list of products then i found another issue when user on my site choose sorting option to price descending then it will still show me outofstock at last in the list?

Please provide me code.

Hi @ppcexpert002,

Welcome to the Algolia Community!

I understand that you would like to have a different sort order when users choose to sort by price descending.

At Algolia, we offer two kinds of sorting strategies: textual ranking which uses a tie-breaking system; and sort by attribute, which allows you to choose something like your price attribute on which to sort.

By design, Algolia provides one ranking formula per index. Every index has a unique sorting strategy, which is statically defined at the index level, and cannot be changed at query time. Pre-sorting at index time instead of at query time leads to a considerable performance boost.

Whenever you want to provide different rankings for the same data, you therefore need to use replica indices .

Replicas have the exact same data as their primary index, and data synchronization is done automatically for you. This way, you can have two different sort strategies for your data.

Multiple ranking formulas are useful to implement different sorting strategies (e.g., sort by price, ascending or descending, sort by most viewed, etc.)

You can create replicas with the dashboard, or you can use the replicas setting when using the API. Whichever method you choose, these actions replicate all data and settings. You then need to change the sorting strategy of the replica.

You can learn more about replica indices here:

This article may also be helpful:

Let us know how this works out for you!