```
public class Solution {
public void wiggleSort(int[] nums) {
if (nums.length == 0 || nums.length == 1)
return;
Arrays.sort(nums);
int[] res = new int[nums.length];
int mid = nums.length/2;
if (nums.length % 2 != 0)
mid++;
int lo = mid - 1;
int hi = nums.length - 1;
for (int i = 0; i < nums.length; i++) {
if (i % 2 == 0) {
res[i] = nums[lo];
lo--;
} else {
res[i] = nums[hi];
hi--;
}
}
for (int i = 0; i < nums.length; i++) {
nums[i] = res[i];
}
}
}
```