Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add example

  • Loading branch information...
commit d29850a670608eecaef5ad38f4f63b61ea332d2c 1 parent b85f807
@tj tj authored
Showing with 47 additions and 0 deletions.
  1. +47 −0 example.html
View
47 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>
Please sign in to comment.
Something went wrong with that request. Please try again.