using System; public class Test { static void Main(string[] args) { int[] newInt = new int[] { 5, -2, -1, -4, -20, 6, 7, -14, 15, -16, 8, 9, 10 }; int size = 12, i= 0; // or newInt.Length int left = 0, right = newInt.Length-1; while (left < right) { if (newInt[left] < 0 && newInt[right] > 0) { int temp = newInt[left]; newInt[left] = newInt[right]; newInt[right] = temp; right--; left++; continue; } if (newInt[left] > 0) { left++; } if (newInt[right] < 0) { right--; } } for (i = 0; i < newInt.Length; i++) { Console.Write(newInt[i]); Console.Write(" "); } } }