First of all, you can answer one simple question: how to sort documents by array? Yes, I donβt know either ..
I believe that you can sort by a specific role using the positioning operator:
db.users.find().sort({'roles.0.name':1})
But I am not sure and I can not check it correctly, and mb is not quite what you need. In any case, you can test and return with the results, otherwise I will find out tomorrow.