-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexample.html
More file actions
47 lines (42 loc) · 841 Bytes
/
example.html
File metadata and controls
47 lines (42 loc) · 841 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
39
40
41
42
43
44
45
46
47
<html>
<head>
<title>Sort</title>
<style type="text/css">
body {
padding: 50px;
font: 12px Helvetica;
}
</style>
</head>
<body>
<ul>
<li>Tobi</li>
<li>Jane</li>
<li>Abby</li>
<li>Loki</li>
<li>Simon</li>
<li>Manny</li>
<li>Luna</li>
</ul>
<button onclick='asc()'>Sort ascending</button>
<button onclick='desc()'>Sort descending</button>
<script type="text/javascript" src="build/build.js"></script>
<script>
var sort = require('sort');
var ul = document.querySelector('ul');
function alpha(a, b){
a = a.textContent;
b = b.textContent;
if (a < b) return -1;
if (a > b) return 1;
return 0;
}
function asc() {
sort(ul, alpha);
}
function desc() {
sort.desc(ul, alpha);
}
</script>
</body>
</html>