Skip to content

Commit

Permalink
add example
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Feb 13, 2013
1 parent b85f807 commit d29850a
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions example.html
@@ -0,0 +1,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>

0 comments on commit d29850a

Please sign in to comment.