// Initialize two pointers to the start and end of the array 
int left = 0; 
int right = array.length - 1; 

// Loop through the array until left and right pointers cross 
while (left < right) { 

// Move left pointer until negative integer is found 
while (array[left] >= 0 && left < right) { 
    left++; 
} 

// Move right pointer until negative integer is found 
while (array[right] < 0 && left < right) { 
    right--; 
} 

// Swap positive and negative integers 
if (left < right) { 
    int temp = array[left]; 
    array[left] = array[right]; 
    array[right] = temp; 
} 

}
// Return rearranged array 
return array;
[3, -4, 2, -1, 7]
Scrivi un algoritmo per riorganizzare un array di numeri interi in un array con tutti gli interi negativi in primo piano.