Sort by optional field

Hi everyone!

Im trying to set up a sort for an api response (using qs to build). I’m familiar with deep sorting and have set this up successfully. However, I need to filter one specific call based on the presence or absence of a field.

Is this possible with the initial api call, or is it something only possible with js sorting on the response?

For instance:

An object could be either of the below:

prop1:"some value"
sortprop:"some value"

prop1:"some value"

How would I write the sort in the qs query so all objects not containing sortprop are moved to the start and those with sortprop to the end? I have tried:


sort: [
          field: "sortprop",
          order: "asc",
          nulls: "always",

Neither work! I know a js solution after the response is possible, but would be neat to do it in one go if possible.

Nevermind. After some further research since the field I am trying to sort by is within a dynamic component it is stored within an array. There does not seem to be an away to sort within an array in this build of strapi. ie sort [“field[0]otherfield”] does not work. If anyone knows different it would be great to hear!