Query and sort by field on entity referenced object
The answer by Clive is correct.
I  used this query for a project :

$query-&gt;sort('field_projets.entity.field_date_mise_en_prod', 'DESC');


'field_projets' is the field name of the entity reference field on my node.

And 'field_date_mise_en_prod' is the name of a date field belonging to the referenced entity .

You can also use this syntax on conditions.
Exemple :

$query-&gt;condition('field_tags.entity.name', 'cats');


You asking for a tag with the name 'cats'.