Order Search Results
There are times when you would like to order search results based on a particular field and in a particular direction. This section take a look at how you can achieve that.
Order by Name
To order the search results depending on the item name, you can provide the following values to the orderBy argument. Feel free to change the direction value to DESC in the playground below to change the direction as well.
Order by Price
To order the search results using the price of the item, you can set the field to PRICE. The query below orders the items starting from the lowest price to the highest price.
Order by Stock
Lastly, you can order the search depending upon the amount of stock each item has. The example query below orders the items starting from the item that has the highest stock to the item that has the lowest stock.