Relation field count & ordering by relation count

can u teach me how to do add this into my code?