Custom sort in non-custom controller

Hi, I created a Place entity using strapi/admin panel. It created standard controller, service and etc.

Now, when get request is happening (find query), I need to sort the Places by distance from current user.

I edited the standard controller, I added new params into ctx.query for user_coordinates.

Now I want to keep the functionality strapi provides out of the box (field params, populate, filters and etc). But I also want to add to SQL query that strapi sends to database my own logic that not just returns
data, but also sorts them by distance

I know how to sort by distance, I just don’t know how to merge the query strapi already does with my sort by distance query.

So it would be one request to the database instead of 2

This topic has been created from a Discord post (1223304713592639631) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord