dose of one's own medicine

[dose of one's own medicine] or [taste of one's own medicine] {n. phr.} Being treated in the same way you treat others; something bad done to you as you have done bad to other people.

Jim was always playing tricks on other boys. Finally they decided to give him a dose of his own medicine.