new helper function JXG.swap()