sort gridview by relation count

hi there

i have 2 tables, imagine tbl_exam and tbl_question

there is no problem in showing question count for each exam in exam gridview, but how can i sort the exam’s gridview by question count?

thanks in advance!

You can define "question_count" attribute in Exam model.

And … look at the following:

http://www.yiiframework.com/doc-2.0/guide-db-active-record.html#selecting-extra-fields

got help from this link:

http://forum.iranphp.org/Thread-مرتب-کردن-بر-اساس-تعداد-relation