Insertion Sort

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