Sorting a repGroup by the count of another repGroup

My users have a list of movies on the user table.

I have search functionality to search for the movies, I want to sort the list of users by the number of movies that match the search criteria.

How do I tackle this?