```
public void wiggleSort(int[] nums) {
boolean larger = true;
for (int i = 1; i < nums.length; i++) {
if (nums[i] > nums[i-1] != larger) {
nums[i] ^= nums[i-1];
nums[i-1] ^= nums[i];
nums[i] ^= nums[i-1];
}
larger = !larger;
}
}
```