Selection Sort

Run Settings
LanguageJavaScript
Language Version
Run Command
const input = [99, 44, 6, 2, 1, 5, 63, 87, 283, 4, 0]; const selectionSort = (a) => { for (let i = 0; i < a.length; i++) { let smallest = i; for (let j = i; j < a.length; j++) { if (a[j] < a[smallest]) { smallest = j; } } let temp = a[i]; a[i] = a[smallest]; a[smallest] = temp; } return a; }; console.log(selectionSort(input));
Editor Settings
Theme
Key bindings
Full width
Lines