sortable and searchable gridview column of RBAC roles

I have set up the yii2-admin extension to manage my RBAC settings. Now, in my users index page I added a column which would show assigned roles to users like so:

'columns' => [



			'header' => Yii::t('app','Roles'),

			'content' => function ($model, $key, $index, $column){

				$auth = Yii::$app->authManager;

				$roles = $auth->getRolesByUser($model->id);

				$string = ' ';

				foreach ($roles as $role) {

					$string .= $role->name . " ";


				return $string;





I’m not sure however how I can make this column sortable and searchable. What table do I have to do a joinWith in my query? auth_assignment??? And seeing as how I can have multiple roles for my users how can I make this table sortable first by number of roles and then alphabetically by username? This way a user with 3 roles would appear before(descending) or after (ascending) a user with 2 roles, and all users with 3 roles would be sorted alphabetically by their usernames.

Thanks in advance for any suggestions.