How to swtich the position of two objects?

I want to if I can switch the position of object A, to object B, and object B, to object A.

  1. Set variable tempPos.X to Object1.X()
  2. Set variable tempPos.Y to Object1.Y()
  3. Set position of Object1 to Object2.X(), Object2.Y()
    4 Set position of Object2 to tempPos.X, tempPos.Y