How to sort by discounted price with Wix Stores in code

Hi there,

I’m looking to sort my dataset, in code, by the discounted price field available in the products collection when using Wix Stores. I am only able to sort by the price field and specifying the discounted price field returns a validation error when I try to set the sort.

Could anyone provide any info on wether or not I can sort by this field, please?

Many thanks!