/ Published in: JavaScript

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<html> <head><title>Javascript Sort</title</head> <body> <script language="javascript"> function generate(s){ var temp = new Array(); temp = s.split('\n'); temp.sort(); var result = ""; var i; for(i=0; i<temp.length; i++) { result += temp[i] + "\n"; } return result; } </script> <form name="myform"> <textarea name="mytext" rows=20 cols=60> Insert lines to sort here. </textarea> <br><br> <input type="button" value="Sort!" onClick="javascript: document.myform.mytext.value = generate(document.myform.mytext.value);"><br><br> </form> </body> </html>
Comments
