Automatic Ticket Assignment Within Group

For automatic ticket assignment customer creates groups, suppose if client lodge a ticket then ticket only assigned to the agent which belongs to the same group from which clients belong. If agent already has pending ticket then such ticket automatically assigned to other agent of same group.