The idea is simple, if `i`

is odd, means `nums[i-1] < nums[i]`

should NOT satisfy. If `i`

is even, `nums[i-1] < nums[i]`

should satisfy. So we can use `^`

to combine the two conditions.

```
for i in range(1, len(nums)):
if (nums[i-1] < nums[i]) ^ ((i&1) == 1):
nums[i-1:i+1] = [nums[i], nums[i - 1]]
```