Selection Sort C#

Run Settings
LanguageC#
Language Version
Run Command
using System; class SelectionSortExample { static void Main() { int[] numbers = { 99, 44, 6, 2, 1, 5, 63, 87, 283, 4, 0 }; SelectionSort(numbers); Console.WriteLine("Sorted Array:"); Console.WriteLine(string.Join(", ", numbers)); } static void SelectionSort(int[] arr) { for (int i = 0; i < arr.Length - 1; i++) { int lowestValueIndex = i; for (int j = i + 1; j < arr.Length; j++) { if (arr[j] < arr[lowestValueIndex]) { lowestValueIndex = j; } } int temp = arr[lowestValueIndex]; arr[lowestValueIndex] = arr[i]; arr[i] = temp; } } }
Editor Settings
Theme
Key bindings
Full width
Lines