You can only swap two elements at a time, so just use one temp variable repeatedly to make the swap.