Swap function to swap items including delimiter