We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2c810f2 commit 314c74aCopy full SHA for 314c74a
Insertion Sort Algorithm/app.js
@@ -0,0 +1,17 @@
1
+(function getValues() {
2
+ insertionSortAlgorithm([9, 1, 4, 5])
3
+})();
4
+
5
6
+function insertionSortAlgorithm(x) {
7
+ for (let i = 1; i < x.length; i++) {
8
+ let key = x[i];
9
+ for (var j = i - 1; j >= 0; j--) {
10
+ if (x[j] > key) x[j + 1] = x[j]
11
+ else break;
12
+ };
13
+ x[j + 1] = key;
14
+ }
15
+ console.log(x);
16
+};
17
0 commit comments