Swapping implemented using tuples instead of a tmp variable