Question about sorting

Hello,

I have a question about sorting.
I have a blog posts which have relations with post comments. I want to sort blog posts by the latest added comment.

When I’m adding sort: [‘comments.publishedAt:desc’] - it does the sorting, but it also duplicates blog posts and shows them as many times as there are comments inside.

How to do this sorting without having posts duplicated?

Thanks!

1 Like

This is a really huge problem with Strapi v4!

Was Not able to find a solution for it. Did you?

The 4.6.0.beta-1
There is relationship sorting in there.

This is not what I am looking for I guess… The problem described by Rufury could be solved with that solution.

My problem is that I want to sort my entity A by the count of relations to entity B. And that still seems to be impossible?

You could write a custom controller/service for that

I could and probably will. But still sounds like a standard functionality that I would expect strapi to provide …

I don’t agree with that someting like that could be a strapi plugin but should not bein strapi core