public static int[] sortBySign(int[] nums){
int startIndex = 0;
int endIndex = nums.length - 1;
while(startIndex < endIndex){
while(nums[startIndex] < 0){
startIndex++;
}
while(nums[endIndex] > 0){
endIndex--;
}
int temp = nums[startIndex];
nums[startIndex] = nums[endIndex];
nums[endIndex] = temp;
startIndex++;
endIndex--;
}
return nums;
}
My code works for sorting positive and negative numbers but I'm not sure how to sort the zeroes as well. The negatives should be on the left side, zeroes in the middle, and positives on the right side. The order does not matter.