-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
38 lines (33 loc) · 967 Bytes
/
index.html
File metadata and controls
38 lines (33 loc) · 967 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sort a array with different way</title>
</head>
<body>
<script>
//with sort method
function SortMethods(array) {
return array.sort((a,b) => a - b)
}
// console.log(SortMethods(array))
// with marge sort algo
let array = [1,5,3,4,9,6];
function MargeSort(arr) {
let l = arr.length - 1;
for (i = 0; i < l; i++){
for (j = 0; j < l + 1; j++){
if (arr[j] > arr[j +1]) {
const element = arr[j];
arr[j + 1] = element
console.log(arr[j + 1])
}
}
}
return arr
}
MargeSort(array)
</script>
</body>
</html>