Go to attributes settings
Store -> Attributes -> Products
Open attribute with the label "Quantity"
Open tab: "Storefront Properties"
Set "Used for Sorting in Product Listing" to "Yes" and save it
Open category where you want your sorting.
Catalog -> Categories
Open your category, now open "Display settings" tab and set "Quantity" in "Default Product Listing Sort By" dropdown
Now to add descending sorting, open tab "Design" and add this xml code here
<referenceContainer name="content"> <referenceBlock name="product_list_toolbar"> <action method="setDefaultDirection"> <argument name="dir" xsi:type="string">desc</argument> </action> </referenceBlock> </referenceContainer>
Refresh frontend category page and see if it is working