int[] arr = {5, 4, 2, 1, 7, 6 }; int temp = 0; List<int> oInt = new List<int>(); for (int write = 0; write < arr.Length; write++) { int sort = 0; for (; sort < arr.Length - 1; sort++) { if (arr[sort] > arr[sort + 1]) { temp = arr[sort + 1]; arr[sort + 1] = arr[sort]; arr[sort] = temp; } } } oInt.AddRange(arr); foreach (int item in oInt) { Console.WriteLine(item); }
Thank you, Govind
int[] arr = {5, 4, 2, 1, 7, 6 };Array.Sort(arr); List<int> oInt = new List<int>();oInt.AddRange(arr); foreach (int item in oInt) { Console.WriteLine(item); }
Login to post response