Posted By

darkphotn on 01/13/08


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

korzhik


Sort text in Javascript


 / Published in: JavaScript
 

  1. <html>
  2. <head><title>Javascript Sort</title</head>
  3. <body>
  4.  
  5. <script language="javascript">
  6. function generate(s){
  7. var temp = new Array();
  8. temp = s.split('\n');
  9. temp.sort();
  10. var result = "";
  11. var i;
  12. for(i=0; i<temp.length; i++) {
  13. result += temp[i] + "\n";
  14. }
  15. return result;
  16. }
  17.  
  18. </script>
  19.  
  20. <form name="myform">
  21. <textarea name="mytext" rows=20 cols=60>
  22. Insert lines to sort here.
  23. </textarea>
  24. <br><br>
  25. <input type="button" value="Sort!" onClick="javascript: document.myform.mytext.value = generate(document.myform.mytext.value);"><br><br>
  26. </form>
  27.  
  28.  
  29.  
  30. </body>
  31. </html>

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: gazane on November 5, 2008

test wtest stest

Posted By: gazane on November 5, 2008

salam, in test, a test,

You need to login to post a comment.