-
Notifications
You must be signed in to change notification settings - Fork 0
/
sort_comma_list.html
96 lines (75 loc) · 2.32 KB
/
sort_comma_list.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Sort comma separated list</title>
<script src="https://code.jquery.com/jquery-2.2.3.min.js" ></script>
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js" ></script>
<script>
$(function() {
$("#reset").click(function() {
$("#input").val("");
$("#output").val("");
});
$("#parse").click(function() {
var outputStr = "";
var inputStr = $("#input").val();
inputStr = inputStr.trim();
var strArray = inputStr.split(",");
outputStr = strArray.sort(function(a,b) {
a = a.trim().toLocaleLowerCase();
b = b.trim().toLocaleLowerCase();
var retVal = a.localeCompare(b);
//console.log("{" + a + "} compared to {"+b+"}=" + retVal);
return retVal;
});
$("#output").val(outputStr);
});
});
</script>
<style>
#sorter {
background-color:rgb(236,236,236);
padding: 15px;
width: 90%;
}
#sorter textarea {
width: 95%;
height: 100px;
border: 2px solid #cccccc;
margin-left: 10px;
}
button {
font-size:14pt;
}
button#reset {
float:right;
}
</style>
</head>
<body>
<h3>Overview</h3>
<p>Sorts a comma delimited list. This will not add or remove any white spaces before or after commas.<br />
To use, just past a comma delimited list in the first text area. Then press the Parse button. The sorted comma delimited list will show in the Output text area. That's it!<br />
This page uses <a href="https://jquery.com">jquery</a></p>
<div id="sorter">
<h3>Sorter</h3>
Enter a comma delimited list of words here...<br />
<textarea id="input" >
</textarea>
<br />
Output...<br />
<textarea id="output" >
</textarea>
<br />
<button id="parse">Sort My List</button>
<button id="reset" >Reset</button>
</div>
<h3>Author</h3>
<p>By Kyle A<br />
<a href="http://iot-thoughts.blogspot.com/" target="_blank" title="Kyle's IoT Blog">IoT Blog</a><br />
<a href="https://plus.google.com/u/0/105807241682986723425" target="_blank" title="Google Plus">Google+</a><br />
<a href="https://www.linkedin.com/in/kyleaa1" target="_blank" title="LinkedIn">LinedIn</a>
</p>
</body>
</html>