The laws of swapping