-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
55 lines (51 loc) · 1.48 KB
/
index.html
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div class="container">
<div class="center">
<p>
Click The given buttons to sort the Array accordingly :
[2,3,5,21,56,767,87,34,65,76, 123,12,17,349]
</p>
<br />
<div class="btn1 container">
<button class="btn" onclick="ascend()">ascend</button>
<button class="btn" onclick="descend()">descend</button>
<button class="btn" onclick="alphabetical()">
Lexicographic order
</button>
</div>
<br />
<div class="container">
<div id="func"><br /></div>
</div>
</div>
</div>
</body>
<script>
const num = [2, 3, 5, 21, 56, 767, 87, 34, 65, 76, 123, 12, 17, 349];
function ascend() {
num.sort(function (a, b) {
return a - b;
});
document.getElementById("func").innerHTML = num;
}
function descend() {
num.sort(function (a, b) {
return b - a;
});
document.getElementById("func").innerHTML = num;
}
function alphabetical() {
num.sort();
document.getElementById("func").innerHTML = num;
}
</script>
</html>