Best approach for sorting by relationship count

I posted a workaround solution here: Relation field count & ordering by relation count - #9 by szilagyi-sandor