A wise teacher once brought balloons to school, told her pupils to blow them up and write their name on one. After the children tossed their balloons into the hall, the teacher moved through the hall mixing them all up. The kids were given five minutes to find the balloon with their name on it, but though they searched frantically, no one found their own balloon.
Then the teacher told them to take the balloon closest to them and give it to the person whose name was on it. In less than two minutes, everyone was holding their own balloon.
The teacher said to the children, “These balloons are like happiness. We won’t find it when we’re only searching for our own. But if we care about someone else’s happiness … it will ultimately help us find our own.”
You're assuming it's easier to find people than balloons, otherwise you don't know the permutation. If several people share a name, you need multiple passes.
I used a form of this, where every processor in an array wanted to request something from another processor in some permutation. If they all know the permutation, then you can skip the request part and send the reply directly to the one who wants it.
In Lisp, you would use mapcar or a related map* function to do this.
Sending the kids in to search for their own balloons sounds like a (poor) sorting algorithm. But having pairs right from the get-go sounds like consing.