1
I think you can do something like this:
from django.db.models import Max
X.objects.annotate(max_z=Max('y__zs__number')).order_by('max_z')
Source:stackexchange.com
1
I think you can do something like this:
from django.db.models import Max
X.objects.annotate(max_z=Max('y__zs__number')).order_by('max_z')