UNPKG
ibowankenobi-mergesort
Version:
latest (0.0.3)
0.0.3
0.0.2
0.0.1
Merge Sort algorithm implementation without recursion, using cached binary trees
ibowankenobi-mergesort
/
src
/
insertionSort.js
21 lines
(20 loc)
•
401 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function
insertionSort
(
arr, l, f, o =
0
){
let
i =
0
, j, u, temp; --l;
while
(i < l){ j = i; u = o + j; temp = arr[u +
1
];
while
(~j &&
f
(arr[u], temp) >
0
){ arr[u +
1
] = arr[u]; --j,--u; } arr[u +
1
] = temp; i++; }
return
arr; }
export
default
insertionSort;