Poetic justice
This idiom or expression like phrase means:
Something bad happening to a person as a result of something bad that the same person has done in the same (or similar) way or manner or setting. An outcome in which virtue is rewarded and evil punished, often in an especially appropriate or ironic manner.
Example:
An attorney defends a murderer and helps him to escape conviction using a little known loophole. The same murderer (or maybe even another person) later murders the attorney (or maybe a member of his family) and is found not guilty by using the same loophole. This is what’s called “Poetic justice”.
Also see:
What goes around, comes around.
