Independent aggregation of related entities, while also sorting by related (in a single statement)
I azm not sure do I undersgtand you correctly, but probably you need to group additional field from authors to have only one value for ORDER. It might be count of athours, or min / max for name or so:
WITH books AS (
  SELECT 1 AS id, 'The 1' AS title
   UNION ALL
  SELECT 2, 'The 2'
   UNION ALL
  SELECT 3, '3'
), authorships AS (
  SELECT 1 AS id, 1 AS book_id, 1 AS author_id
   UNION ALL
  SELECT 2, 1, 2
   UNION ALL
  SELECT 3, 1, 3
   UNION ALL
  SELECT 4, 2, 1
   UNION ALL
  SELECT 5, 3, 1
), authors AS (
  SELECT 1 AS id, 'name1' AS name
   UNION ALL
  SELECT 2, 'name2'
   UNION ALL
  SELECT 3, 'name3'
   UNION ALL
  SELECT 4, 'name4'
), filtered AS (
  SELECT book_id, title, ba.id, author_id, name
    FROM books AS b
    JOIN authorships AS ba ON ba.book_id = b.id
    JOIN authors AS a ON a.id = ba.author_id WHERE title LIKE 'The %'
) 
SELECT (
         SELECT json_agg(b.* ORDER BY count)
           FROM (
                  SELECT book_id AS id, title, count(name)
                    FROM filtered AS f GROUP BY 1,2
                ) AS f
           JOIN LATERAL (SELECT id, title) AS b ON true)
       ) AS book 

           json_agg           
-----------------------------
 [{&quot;id&quot;:2,&quot;title&quot;:&quot;The 2&quot;}, +
  {&quot;id&quot;:1,&quot;title&quot;:&quot;The 1&quot;}]
(1 row)